| Function (anonymous_1) | |
|---|---|
| ✓ Was called | var Checker = function() {··· StringChecker.apply(this, arguments); }; |
| Function (anonymous_2) | |
|---|---|
| ✓ Was called | Checker.prototype.configure = function(config) {··· StringChecker.prototype.configure.call(this, config); this._fileExtensions = this._configuration.getFileExtensions(); }; |
| Function (anonymous_3) | |
|---|---|
| ✓ Was called | Checker.prototype.execute = function() {··· var method = this._configuration.getFix() === true ? this.fixPath : this.checkPath; return method.apply(this, arguments); }; |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | var method = this._configuration.getFix() === true ? this.fixPath : this.checkPath; |
| ✓ Negative was returned (: ...) | var method = this._configuration.getFix() === true ? this.fixPath : this.checkPath; |
| Function (anonymous_4) | |
|---|---|
| ✓ Was called | Checker.prototype.checkFile = function(path) {··· if (this._configuration.isFileExcluded(path)) { return Vow.resolve(null); } return vowFs.read(path, 'utf8').then(function(data) { return this.checkString(data, path); }, this); }; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._configuration.isFileExcluded(path)) {··· return Vow.resolve(null); } |
| ✓ Negative was executed (else) | }··· return vowFs.read(path, 'utf8').then(function(data) { |
| Function (anonymous_5) | |
|---|---|
| ✓ Was called | return vowFs.read(path, 'utf8').then(function(data) {··· return this.checkString(data, path); }, this); |
| Function (anonymous_6) | |
|---|---|
| ✓ Was called | Checker.prototype.fixFile = function(path) {··· if (this._configuration.isFileExcluded(path)) { return Vow.resolve(null); } return vowFs.read(path, 'utf8').then(function(data) { var result = this.fixString(data, path); return vowFs.write(path, result.output).then(function() { return result.errors; }); }, this); }; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._configuration.isFileExcluded(path)) {··· return Vow.resolve(null); } |
| ✓ Negative was executed (else) | }··· return vowFs.read(path, 'utf8').then(function(data) { |
| Function (anonymous_7) | |
|---|---|
| ✓ Was called | return vowFs.read(path, 'utf8').then(function(data) {··· var result = this.fixString(data, path); return vowFs.write(path, result.output).then(function() { return result.errors; }); }, this); |
| Function (anonymous_8) | |
|---|---|
| ✓ Was called | return vowFs.write(path, result.output).then(function() {··· return result.errors; }); |
| Function (anonymous_9) | |
|---|---|
| ✓ Was called | Checker.prototype.extractFile = function(path) {··· if (this._configuration.isFileExcluded(path)) { return Vow.resolve(null); } if (!this._configuration.shouldExtractFile(path)) { return Vow.resolve(null); } return vowFs.read(path, 'utf8').then(function(data) { var result = extractJs(path, data); result.sources.forEach(function(script) { this.checkString(script.source, path).getErrorList().forEach(function(error) { error.line += script.line; error.column += script.offset; result.addError(error); }); }, this); return result.errors; }, this); }; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._configuration.isFileExcluded(path)) {··· return Vow.resolve(null); } |
| ✓ Negative was executed (else) | }··· if (!this._configuration.shouldExtractFile(path)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!this._configuration.shouldExtractFile(path)) {··· return Vow.resolve(null); } |
| ✓ Negative was executed (else) | }··· return vowFs.read(path, 'utf8').then(function(data) { |
| Function (anonymous_10) | |
|---|---|
| ✓ Was called | return vowFs.read(path, 'utf8').then(function(data) {··· var result = extractJs(path, data); result.sources.forEach(function(script) { this.checkString(script.source, path).getErrorList().forEach(function(error) { error.line += script.line; error.column += script.offset; result.addError(error); }); }, this); return result.errors; }, this); |
| Function (anonymous_11) | |
|---|---|
| ✓ Was called | result.sources.forEach(function(script) {··· this.checkString(script.source, path).getErrorList().forEach(function(error) { error.line += script.line; error.column += script.offset; result.addError(error); }); }, this); |
| Function (anonymous_12) | |
|---|---|
| ✓ Was called | this.checkString(script.source, path).getErrorList().forEach(function(error) {··· error.line += script.line; error.column += script.offset; result.addError(error); }); |
| Function (anonymous_13) | |
|---|---|
| ✓ Was called | Checker.prototype.checkDirectory = function(path) {··· return this._processDirectory(path, this.checkFile.bind(this)); }; |
| Function (anonymous_14) | |
|---|---|
| ✓ Was called | Checker.prototype.checkPath = function(path) {··· return this._processPath(path, this.checkFile.bind(this)); }; |
| Function (anonymous_15) | |
|---|---|
| ✓ Was called | Checker.prototype.fixPath = function(path) {··· return this._processPath(path, this.fixFile.bind(this)); }; |
| Function (anonymous_16) | |
|---|---|
| ✓ Was called | Checker.prototype._processDirectory = function(path, fileHandler) {··· return vowFs.listDir(path).then(function(filenames) { return Vow.all(filenames.map(function(filename) { var fullname = path + '/' + filename; if (this._configuration.isFileExcluded(fullname)) { return []; } return vowFs.stat(fullname).then(function(stat) { if (stat.isDirectory()) { return this._processDirectory(fullname, fileHandler); } if (!this._hasCorrectExtension(fullname)) { if (!this._configuration.shouldExtractFile(fullname)) { return []; } return this.extractFile(fullname); } return fileHandler(fullname); }, this); }, this)).then(function(results) { return [].concat.apply([], results); }); }, this); }; |
| Function (anonymous_17) | |
|---|---|
| ✓ Was called | return vowFs.listDir(path).then(function(filenames) {··· return Vow.all(filenames.map(function(filename) { var fullname = path + '/' + filename; if (this._configuration.isFileExcluded(fullname)) { return []; } return vowFs.stat(fullname).then(function(stat) { if (stat.isDirectory()) { return this._processDirectory(fullname, fileHandler); } if (!this._hasCorrectExtension(fullname)) { if (!this._configuration.shouldExtractFile(fullname)) { return []; } return this.extractFile(fullname); } return fileHandler(fullname); }, this); }, this)).then(function(results) { return [].concat.apply([], results); }); }, this); |
| Function (anonymous_18) | |
|---|---|
| ✓ Was called | return Vow.all(filenames.map(function(filename) {··· var fullname = path + '/' + filename; if (this._configuration.isFileExcluded(fullname)) { return []; } return vowFs.stat(fullname).then(function(stat) { if (stat.isDirectory()) { return this._processDirectory(fullname, fileHandler); } if (!this._hasCorrectExtension(fullname)) { if (!this._configuration.shouldExtractFile(fullname)) { return []; } return this.extractFile(fullname); } return fileHandler(fullname); }, this); }, this)).then(function(results) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._configuration.isFileExcluded(fullname)) {··· return []; } |
| ✓ Negative was executed (else) | }··· return vowFs.stat(fullname).then(function(stat) { |
| Function (anonymous_19) | |
|---|---|
| ✓ Was called | return vowFs.stat(fullname).then(function(stat) {··· if (stat.isDirectory()) { return this._processDirectory(fullname, fileHandler); } if (!this._hasCorrectExtension(fullname)) { if (!this._configuration.shouldExtractFile(fullname)) { return []; } return this.extractFile(fullname); } return fileHandler(fullname); }, this); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (stat.isDirectory()) {··· return this._processDirectory(fullname, fileHandler); } |
| ✓ Negative was executed (else) | }··· if (!this._hasCorrectExtension(fullname)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!this._hasCorrectExtension(fullname)) {··· if (!this._configuration.shouldExtractFile(fullname)) { return []; } return this.extractFile(fullname); } |
| ✓ Negative was executed (else) | }··· return fileHandler(fullname); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!this._configuration.shouldExtractFile(fullname)) {··· return []; } |
| ✓ Negative was executed (else) | }··· return this.extractFile(fullname); |
| Function (anonymous_20) | |
|---|---|
| ✓ Was called | }, this)).then(function(results) {··· return [].concat.apply([], results); }); |
| Function (anonymous_21) | |
|---|---|
| ✓ Was called | Checker.prototype._processPath = function(path, fileHandler) {··· path = path.replace(/\/$/, ''); return vowFs.exists(path).then(function(exists) { if (!exists) { throw new Error('Path ' + path + ' was not found.'); } return vowFs.stat(path).then(function(stat) { if (stat.isDirectory()) { return this._processDirectory(path, fileHandler); } return fileHandler(path).then(function(errors) { if (errors) { return [errors]; } return []; }); }, this); }, this); }; |
| Function (anonymous_22) | |
|---|---|
| ✓ Was called | return vowFs.exists(path).then(function(exists) {··· if (!exists) { throw new Error('Path ' + path + ' was not found.'); } return vowFs.stat(path).then(function(stat) { if (stat.isDirectory()) { return this._processDirectory(path, fileHandler); } return fileHandler(path).then(function(errors) { if (errors) { return [errors]; } return []; }); }, this); }, this); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!exists) {··· throw new Error('Path ' + path + ' was not found.'); } |
| ✓ Negative was executed (else) | }··· return vowFs.stat(path).then(function(stat) { |
| Function (anonymous_23) | |
|---|---|
| ✓ Was called | return vowFs.stat(path).then(function(stat) {··· if (stat.isDirectory()) { return this._processDirectory(path, fileHandler); } return fileHandler(path).then(function(errors) { if (errors) { return [errors]; } return []; }); }, this); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (stat.isDirectory()) {··· return this._processDirectory(path, fileHandler); } |
| ✓ Negative was executed (else) | }··· return fileHandler(path).then(function(errors) { |
| Function (anonymous_24) | |
|---|---|
| ✓ Was called | return fileHandler(path).then(function(errors) {··· if (errors) { return [errors]; } return []; }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (errors) {··· return [errors]; } |
| ✓ Negative was executed (else) | }··· return []; |
| Function (anonymous_25) | |
|---|---|
| ✓ Was called | Checker.prototype.checkStdin = function() {··· return this._processStdin(this.checkString.bind(this)); }; |
| Function (anonymous_26) | |
|---|---|
| ✓ Was called | Checker.prototype.fixStdin = function() {··· return this._processStdin(this.fixString.bind(this)); }; |
| Function (anonymous_27) | |
|---|---|
| ✓ Was called | Checker.prototype._processStdin = function(stdinHandler) {··· var stdInput = []; var deferred = Vow.defer(); process.stdin.setEncoding('utf8'); process.stdin.on('data', function(chunk) { stdInput.push(chunk); }); process.stdin.on('end', function() { deferred.resolve(stdinHandler(stdInput.join(''))); }); return deferred.promise(); }; |
| Function (anonymous_28) | |
|---|---|
| ✓ Was called | process.stdin.on('data', function(chunk) {··· stdInput.push(chunk); }); |
| Function (anonymous_29) | |
|---|---|
| ✓ Was called | process.stdin.on('end', function() {··· deferred.resolve(stdinHandler(stdInput.join(''))); }); |
| Function (anonymous_30) | |
|---|---|
| ✓ Was called | Checker.prototype._hasCorrectExtension = function(testPath) {··· var extension = path.extname(testPath).toLowerCase(); var basename = path.basename(testPath).toLowerCase(); return !( this._fileExtensions.indexOf(extension) < 0 && this._fileExtensions.indexOf(basename) < 0 && this._fileExtensions.indexOf('*') < 0 ); }; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | this._fileExtensions.indexOf('*') < 0 |
| ✓ Was returned | this._fileExtensions.indexOf(extension) < 0 &&··· this._fileExtensions.indexOf(basename) < 0 && |
| Branch LogicalExpression | |
| ✓ Was returned | this._fileExtensions.indexOf(basename) < 0 && |
| ✓ Was returned | this._fileExtensions.indexOf(extension) < 0 && |
| Function (anonymous_31) | |
|---|---|
| ✓ Was called | Checker.prototype._createConfiguration = function() {··· return new NodeConfiguration(); }; |
| Function getInternalErrorMessage | |
|---|---|
| ✓ Was called | function getInternalErrorMessage(rule, e) {··· return 'Error running rule ' + rule + ': ' + 'This is an issue with JSCS and not your codebase.\n' + 'Please file an issue (with the stack trace below) at: ' + 'https://github.com/jscs-dev/node-jscs/issues/new\n' + e; } |
| Function (anonymous_33) | |
|---|---|
| ✓ Was called | var StringChecker = function() {··· this._configuredRules = []; this._errorsFound = 0; this._maxErrorsExceeded = false; // Need to be defined here because Configuration module can choose // custom esprima or chose parsers based on "esnext" option this._esprima = esprima; this._configuration = this._createConfiguration(); this._configuration.registerDefaultPresets(); }; |
| Function (anonymous_34) | |
|---|---|
| ✓ Was called | registerRule: function(rule) {··· this._configuration.registerRule(rule); }, |
| Function (anonymous_35) | |
|---|---|
| ✓ Was called | registerDefaultRules: function() {··· this._configuration.registerDefaultRules(); }, |
| Function (anonymous_36) | |
|---|---|
| ✗ Was not called | getProcessedConfig: function() {··· return this._configuration.getProcessedConfig(); }, |
| Function (anonymous_37) | |
|---|---|
| ✓ Was called | configure: function(config) {··· this._configuration.load(config); if (this._configuration.hasCustomEsprima()) { this._esprima = this._configuration.getCustomEsprima(); } else if (this._configuration.isESNextEnabled()) { this._esprima = babelJscs; } this._verbose = this._configuration.getVerbose(); this._configuredRules = this._configuration.getConfiguredRules(); this._maxErrors = this._configuration.getMaxErrors(); }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._configuration.hasCustomEsprima()) {··· this._esprima = this._configuration.getCustomEsprima(); } else if (this._configuration.isESNextEnabled()) { |
| ✓ Negative was executed (else) | } else if (this._configuration.isESNextEnabled()) {··· this._esprima = babelJscs; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (this._configuration.isESNextEnabled()) {··· this._esprima = babelJscs; } |
| ✓ Negative was executed (else) | }··· this._verbose = this._configuration.getVerbose(); |
| Function (anonymous_38) | |
|---|---|
| ✓ Was called | checkString: function(source, filename) {··· filename = filename || 'input'; var file = this._createJsFileInstance(filename, source); var errors = new Errors(file, this._verbose); file.getParseErrors().forEach(function(parseError) { if (!this._maxErrorsExceeded) { this._addParseError(errors, parseError); } }, this); // Do not check empty strings if (file.getFirstToken({includeComments: true}).type === 'EOF') { return errors; } this._checkJsFile(file, errors); return errors; }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | filename = filename || 'input'; |
| ✓ Was returned | filename = filename || 'input'; |
| Function (anonymous_39) | |
|---|---|
| ✓ Was called | file.getParseErrors().forEach(function(parseError) {··· if (!this._maxErrorsExceeded) { this._addParseError(errors, parseError); } }, this); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!this._maxErrorsExceeded) {··· this._addParseError(errors, parseError); } |
| ✗ Negative was not executed (else) | }··· }, this); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (file.getFirstToken({includeComments: true}).type === 'EOF') {··· return errors; } |
| ✓ Negative was executed (else) | }··· this._checkJsFile(file, errors); |
| Function (anonymous_40) | |
|---|---|
| ✓ Was called | _fixJsFile: function(file, errors) {··· var list = errors.getErrorList(); var configuration = this.getConfiguration(); list.forEach(function(error) { if (error.fixed) { return; } var instance = configuration.getConfiguredRule(error.rule); if (instance && instance._fix) { try { // "error.fixed = true" should go first, so rule can // decide for itself (with "error.fixed = false") // if it can fix this particular error error.fixed = true; instance._fix(file, error); } catch (e) { error.fixed = undefined; errors.add(getInternalErrorMessage(error.rule, e), 1, 0); } } }); }, |
| Function (anonymous_41) | |
|---|---|
| ✓ Was called | list.forEach(function(error) {··· if (error.fixed) { return; } var instance = configuration.getConfiguredRule(error.rule); if (instance && instance._fix) { try { // "error.fixed = true" should go first, so rule can // decide for itself (with "error.fixed = false") // if it can fix this particular error error.fixed = true; instance._fix(file, error); } catch (e) { error.fixed = undefined; errors.add(getInternalErrorMessage(error.rule, e), 1, 0); } } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (error.fixed) {··· return; } |
| ✓ Negative was executed (else) | }··· var instance = configuration.getConfiguredRule(error.rule); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (instance && instance._fix) {··· try { // "error.fixed = true" should go first, so rule can // decide for itself (with "error.fixed = false") // if it can fix this particular error error.fixed = true; instance._fix(file, error); } catch (e) { error.fixed = undefined; errors.add(getInternalErrorMessage(error.rule, e), 1, 0); } } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | if (instance && instance._fix) { |
| ✗ Was not returned | if (instance && instance._fix) { |
| Function (anonymous_42) | |
|---|---|
| ✓ Was called | _checkJsFile: function(file, errors) {··· if (this._maxErrorsExceeded) { return; } var errorFilter = this._configuration.getErrorFilter(); this._configuredRules.forEach(function(rule) { errors.setCurrentRule(rule.getOptionName()); try { rule.check(file, errors); } catch (e) { errors.setCurrentRule('internalError'); errors.add(getInternalErrorMessage(rule.getOptionName(), e.stack), 1, 0); } }, this); this._configuration.getUnsupportedRuleNames().forEach(function(rulename) { errors.add('Unsupported rule: ' + rulename, 1, 0); }); // sort errors list to show errors as they appear in source errors.getErrorList().sort(function(a, b) { return (a.line - b.line) || (a.column - b.column); }); if (errorFilter) { errors.filter(errorFilter); } if (this.maxErrorsEnabled()) { if (this._maxErrors === -1 || this._maxErrors === null) { this._maxErrorsExceeded = false; } else { this._maxErrorsExceeded = this._errorsFound + errors.getErrorCount() > this._maxErrors; errors.stripErrorList(Math.max(0, this._maxErrors - this._errorsFound)); } } this._errorsFound += errors.getErrorCount(); }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._maxErrorsExceeded) {··· return; } |
| ✓ Negative was executed (else) | }··· var errorFilter = this._configuration.getErrorFilter(); |
| Function (anonymous_43) | |
|---|---|
| ✓ Was called | this._configuredRules.forEach(function(rule) {··· errors.setCurrentRule(rule.getOptionName()); try { rule.check(file, errors); } catch (e) { errors.setCurrentRule('internalError'); errors.add(getInternalErrorMessage(rule.getOptionName(), e.stack), 1, 0); } }, this); |
| Function (anonymous_44) | |
|---|---|
| ✓ Was called | this._configuration.getUnsupportedRuleNames().forEach(function(rulename) {··· errors.add('Unsupported rule: ' + rulename, 1, 0); }); |
| Function (anonymous_45) | |
|---|---|
| ✓ Was called | errors.getErrorList().sort(function(a, b) {··· return (a.line - b.line) || (a.column - b.column); }); |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | return (a.line - b.line) || (a.column - b.column); |
| ✓ Was returned | return (a.line - b.line) || (a.column - b.column); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (errorFilter) {··· errors.filter(errorFilter); } |
| ✓ Negative was executed (else) | }··· if (this.maxErrorsEnabled()) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this.maxErrorsEnabled()) {··· if (this._maxErrors === -1 || this._maxErrors === null) { this._maxErrorsExceeded = false; } else { this._maxErrorsExceeded = this._errorsFound + errors.getErrorCount() > this._maxErrors; errors.stripErrorList(Math.max(0, this._maxErrors - this._errorsFound)); } } |
| ✓ Negative was executed (else) | }··· this._errorsFound += errors.getErrorCount(); |
| Branch IfStatement | |
|---|---|
| ✗ Positive was not executed (if) | if (this._maxErrors === -1 || this._maxErrors === null) {··· this._maxErrorsExceeded = false; } else { |
| ✓ Negative was executed (else) | } else {··· this._maxErrorsExceeded = this._errorsFound + errors.getErrorCount() > this._maxErrors; errors.stripErrorList(Math.max(0, this._maxErrors - this._errorsFound)); } |
| Branch LogicalExpression | |
| ✓ Was returned | if (this._maxErrors === -1 || this._maxErrors === null) { |
| ✗ Was not returned | if (this._maxErrors === -1 || this._maxErrors === null) { |
| Function (anonymous_46) | |
|---|---|
| ✓ Was called | _addParseError: function(errors, parseError) {··· if (this._maxErrorsExceeded) { return; } errors.setCurrentRule('parseError'); errors.add(parseError.description, parseError.lineNumber, parseError.column); if (this.maxErrorsEnabled()) { this._errorsFound += 1; this._maxErrorsExceeded = this._errorsFound >= this._maxErrors; } }, |
| Branch IfStatement | |
|---|---|
| ✗ Positive was not executed (if) | if (this._maxErrorsExceeded) {··· return; } |
| ✓ Negative was executed (else) | }··· errors.setCurrentRule('parseError'); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this.maxErrorsEnabled()) {··· this._errorsFound += 1; this._maxErrorsExceeded = this._errorsFound >= this._maxErrors; } |
| ✗ Negative was not executed (else) | }··· }, |
| Function (anonymous_47) | |
|---|---|
| ✓ Was called | _createJsFileInstance: function(filename, source) {··· return new JsFile({ filename: filename, source: source, esprima: this._esprima, esprimaOptions: this._configuration.getEsprimaOptions(), es3: this._configuration.isES3Enabled(), es6: this._configuration.isESNextEnabled() }); }, |
| Function (anonymous_48) | |
|---|---|
| ✓ Was called | fixString: function(source, filename) {··· filename = filename || 'input'; var file = this._createJsFileInstance(filename, source); var errors = new Errors(file, this._verbose); var parseErrors = file.getParseErrors(); if (parseErrors.length > 0) { parseErrors.forEach(function(parseError) { this._addParseError(errors, parseError); }, this); return {output: source, errors: errors}; } else { var attempt = 0; do { // Changes to current sources are made in rules through assertions. this._checkJsFile(file, errors); // If assertions weren't used but rule has "fix" method, // which we could use. this._fixJsFile(file, errors); var hasFixes = errors.getErrorList().some(function(err) { return err.fixed; }); if (!hasFixes) { break; } file = this._createJsFileInstance(filename, file.render()); errors = new Errors(file, this._verbose); attempt++; } while (attempt < MAX_FIX_ATTEMPTS); return {output: file.getSource(), errors: errors}; } }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | filename = filename || 'input'; |
| ✓ Was returned | filename = filename || 'input'; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (parseErrors.length > 0) {··· parseErrors.forEach(function(parseError) { this._addParseError(errors, parseError); }, this); return {output: source, errors: errors}; } else { |
| ✓ Negative was executed (else) | } else {··· var attempt = 0; do { // Changes to current sources are made in rules through assertions. this._checkJsFile(file, errors); // If assertions weren't used but rule has "fix" method, // which we could use. this._fixJsFile(file, errors); var hasFixes = errors.getErrorList().some(function(err) { return err.fixed; }); if (!hasFixes) { break; } file = this._createJsFileInstance(filename, file.render()); errors = new Errors(file, this._verbose); attempt++; } while (attempt < MAX_FIX_ATTEMPTS); return {output: file.getSource(), errors: errors}; } |
| Function (anonymous_49) | |
|---|---|
| ✓ Was called | parseErrors.forEach(function(parseError) {··· this._addParseError(errors, parseError); }, this); |
| Function (anonymous_50) | |
|---|---|
| ✓ Was called | var hasFixes = errors.getErrorList().some(function(err) {··· return err.fixed; }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!hasFixes) {··· break; } |
| ✓ Negative was executed (else) | }··· file = this._createJsFileInstance(filename, file.render()); |
| Function (anonymous_51) | |
|---|---|
| ✓ Was called | maxErrorsEnabled: function() {··· return this._maxErrors !== null && this._maxErrors !== -1; }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | return this._maxErrors !== null && this._maxErrors !== -1; |
| ✓ Was returned | return this._maxErrors !== null && this._maxErrors !== -1; |
| Function (anonymous_52) | |
|---|---|
| ✓ Was called | maxErrorsExceeded: function() {··· return this._maxErrorsExceeded; }, |
| Function (anonymous_53) | |
|---|---|
| ✓ Was called | _createConfiguration: function() {··· return new Configuration(); }, |
| Function (anonymous_54) | |
|---|---|
| ✓ Was called | getConfiguration: function() {··· return this._configuration; }, |
| Function (anonymous_55) | |
|---|---|
| ✓ Was called | getEsprima: function() {··· return this._esprima || this._configuration.getCustomEsprima(); } |
| Branch LogicalExpression | |
|---|---|
| ✗ Was not returned | return this._esprima || this._configuration.getCustomEsprima(); |
| ✓ Was returned | return this._esprima || this._configuration.getCustomEsprima(); |
| Function (anonymous_56) | |
|---|---|
| ✓ Was called | var Errors = function(file, verbose) {··· this._errorList = []; this._file = file; this._currentRule = ''; this._verbose = verbose || false; /** * @type {TokenAssert} * @public */ this.assert = new TokenAssert(file); this.assert.on('error', this._addError.bind(this)); }; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | this._verbose = verbose || false; |
| ✓ Was returned | this._verbose = verbose || false; |
| Function (anonymous_57) | |
|---|---|
| ✓ Was called | add: function(message, line, column) {··· if (typeof line === 'object') { column = line.column; line = line.line; } var errorInfo = { message: message, line: line, column: column }; this._validateInput(errorInfo); this._addError(errorInfo); }, |
| Branch IfStatement | |
|---|---|
| ✗ Positive was not executed (if) | if (typeof line === 'object') {··· column = line.column; line = line.line; } |
| ✓ Negative was executed (else) | }··· var errorInfo = { |
| Function (anonymous_58) | |
|---|---|
| ✓ Was called | cast: function(errorInfo) {··· var additional = errorInfo.additional; assert(typeof additional !== undefined, '`additional` argument should not be empty'); this._addError(errorInfo); }, |
| Function (anonymous_59) | |
|---|---|
| ✓ Was called | _validateInput: function(errorInfo) {··· var line = errorInfo.line; var column = errorInfo.column; // line and column numbers should be explicit assert(typeof line === 'number' && line > 0, 'Unable to add an error, `line` should be a number greater than 0 but ' + line + ' given'); assert(typeof column === 'number' && column >= 0, 'Unable to add an error, `column` should be a positive number but ' + column + ' given'); }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | assert(typeof line === 'number' && line > 0, |
| ✓ Was returned | assert(typeof line === 'number' && line > 0, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | assert(typeof column === 'number' && column >= 0, |
| ✓ Was returned | assert(typeof column === 'number' && column >= 0, |
| Function (anonymous_60) | |
|---|---|
| ✓ Was called | _addError: function(errorInfo) {··· if (!this._file.isEnabledRule(this._currentRule, errorInfo.line)) { return; } this._validateInput(errorInfo); this._errorList.push({ filename: this._file.getFilename(), rule: this._currentRule, message: this._prepareMessage(errorInfo), line: errorInfo.line, column: errorInfo.column, additional: errorInfo.additional, fixed: errorInfo.fixed }); }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!this._file.isEnabledRule(this._currentRule, errorInfo.line)) {··· return; } |
| ✓ Negative was executed (else) | }··· this._validateInput(errorInfo); |
| Function (anonymous_61) | |
|---|---|
| ✓ Was called | _prepareMessage: function(errorInfo) {··· if (this._verbose && this._currentRule) { return this._currentRule + ': ' + errorInfo.message; } return errorInfo.message; }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._verbose && this._currentRule) {··· return this._currentRule + ': ' + errorInfo.message; } |
| ✓ Negative was executed (else) | }··· return errorInfo.message; |
| Branch LogicalExpression | |
| ✓ Was returned | if (this._verbose && this._currentRule) { |
| ✓ Was returned | if (this._verbose && this._currentRule) { |
| Function (anonymous_62) | |
|---|---|
| ✓ Was called | getErrorList: function() {··· return this._errorList; }, |
| Function (anonymous_63) | |
|---|---|
| ✓ Was called | getFilename: function() {··· return this._file.getFilename(); }, |
| Function (anonymous_64) | |
|---|---|
| ✗ Was not called | isEmpty: function() {··· return this._errorList.length === 0; }, |
| Function (anonymous_65) | |
|---|---|
| ✓ Was called | getErrorCount: function() {··· return this._errorList.length; }, |
| Function (anonymous_66) | |
|---|---|
| ✓ Was called | stripErrorList: function(length) {··· this._errorList.splice(length); }, |
| Function (anonymous_67) | |
|---|---|
| ✓ Was called | filter: function(filter) {··· this._errorList = this._errorList.filter(filter); }, |
| Function (anonymous_68) | |
|---|---|
| ✓ Was called | explainError: function(error, colorize) {··· var lineNumber = error.line - 1; var lines = this._file.getLines(); var result = [ renderLine(lineNumber, lines[lineNumber], colorize), renderPointer(error.column, colorize) ]; var i = lineNumber - 1; var linesAround = 2; while (i >= 0 && i >= (lineNumber - linesAround)) { result.unshift(renderLine(i, lines[i], colorize)); i--; } i = lineNumber + 1; while (i < lines.length && i <= (lineNumber + linesAround)) { result.push(renderLine(i, lines[i], colorize)); i++; } result.unshift(formatErrorMessage(error.message, this.getFilename(), colorize)); return result.join('\n'); }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | while (i >= 0 && i >= (lineNumber - linesAround)) { |
| ✓ Was returned | while (i >= 0 && i >= (lineNumber - linesAround)) { |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | while (i < lines.length && i <= (lineNumber + linesAround)) { |
| ✓ Was returned | while (i < lines.length && i <= (lineNumber + linesAround)) { |
| Function (anonymous_69) | |
|---|---|
| ✓ Was called | setCurrentRule: function(rule) {··· this._currentRule = rule; } |
| Function formatErrorMessage | |
|---|---|
| ✓ Was called | function formatErrorMessage(message, filename, colorize) {··· return (colorize ? chalk.bold(message) : message) + ' at ' + (colorize ? chalk.green(filename) : filename) + ' :'; } |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | return (colorize ? chalk.bold(message) : message) + |
| ✓ Negative was returned (: ...) | return (colorize ? chalk.bold(message) : message) + |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | (colorize ? chalk.green(filename) : filename) + ' :'; |
| ✓ Negative was returned (: ...) | (colorize ? chalk.green(filename) : filename) + ' :'; |
| Function prependSpaces | |
|---|---|
| ✓ Was called | function prependSpaces(s, len) {··· while (s.length < len) { s = ' ' + s; } return s; } |
| Function renderLine | |
|---|---|
| ✓ Was called | function renderLine(n, line, colorize) {··· // Convert tabs to spaces, so errors in code lines with tabs as indention symbol // could be correctly rendered, plus it will provide less verbose output line = line.replace(/\t/g, ' '); // "n + 1" to print lines in human way (counted from 1) var lineNumber = prependSpaces((n + 1).toString(), 5) + ' |'; return ' ' + (colorize ? chalk.grey(lineNumber) : lineNumber) + line; } |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | return ' ' + (colorize ? chalk.grey(lineNumber) : lineNumber) + line; |
| ✓ Negative was returned (: ...) | return ' ' + (colorize ? chalk.grey(lineNumber) : lineNumber) + line; |
| Function renderPointer | |
|---|---|
| ✓ Was called | function renderPointer(column, colorize) {··· var res = (new Array(column + 9)).join('-') + '^'; return colorize ? chalk.grey(res) : res; } |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | return colorize ? chalk.grey(res) : res; |
| ✓ Negative was returned (: ...) | return colorize ? chalk.grey(res) : res; |
| Function TokenAssert | |
|---|---|
| ✓ Was called | function TokenAssert(file) {··· EventEmitter.call(this); this._file = file; } |
| Function (anonymous_75) | |
|---|---|
| ✓ Was called | TokenAssert.prototype.whitespaceBetween = function(options) {··· options.atLeast = 1; this.spacesBetween(options); }; |
| Function (anonymous_76) | |
|---|---|
| ✓ Was called | TokenAssert.prototype.noWhitespaceBetween = function(options) {··· options.exactly = 0; this.spacesBetween(options); }; |
| Function (anonymous_77) | |
|---|---|
| ✓ Was called | TokenAssert.prototype.spacesBetween = function(options) {··· var token = options.token; var nextToken = options.nextToken; var atLeast = options.atLeast; var atMost = options.atMost; var exactly = options.exactly; if (!token || !nextToken) { return; } this._validateOptions(options); if (!options.disallowNewLine && token.loc.end.line !== nextToken.loc.start.line) { return; } // Only attempt to remove or add lines if there are no comments between the two nodes // as this prevents accidentally moving a valid token onto a line comment ed line var fixed = this._file.getNextToken(options.token, { includeComments: true }) === nextToken; var emitError = function(countPrefix, spaceCount) { if (fixed) { this._file.setWhitespaceBefore(nextToken, new Array(spaceCount + 1).join(' ')); } var msgPostfix = token.value + ' and ' + nextToken.value; if (!options.message) { if (exactly === 0) { // support noWhitespaceBetween options.message = 'Unexpected whitespace between ' + msgPostfix; } else if (exactly !== undefined) { // support whitespaceBetween (spaces option) options.message = spaceCount + ' spaces required between ' + msgPostfix; } else if (atLeast === 1 && atMost === undefined) { // support whitespaceBetween (no spaces option) options.message = 'Missing space between ' + msgPostfix; } else { options.message = countPrefix + ' ' + spaceCount + ' spaces required between ' + msgPostfix; } } this.emit('error', { message: options.message, line: token.loc.end.line, column: token.loc.end.column, fixed: fixed }); }.bind(this); var spacesBetween = Math.abs(nextToken.range[0] - token.range[1]); if (atLeast !== undefined && spacesBetween < atLeast) { emitError('at least', atLeast); } else if (atMost !== undefined && spacesBetween > atMost) { emitError('at most', atMost); } else if (exactly !== undefined && spacesBetween !== exactly) { emitError('exactly', exactly); } }; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!token || !nextToken) {··· return; } |
| ✓ Negative was executed (else) | }··· this._validateOptions(options); |
| Branch LogicalExpression | |
| ✓ Was returned | if (!token || !nextToken) { |
| ✓ Was returned | if (!token || !nextToken) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!options.disallowNewLine && token.loc.end.line !== nextToken.loc.start.line) {··· return; } |
| ✓ Negative was executed (else) | }··· // Only attempt to remove or add lines if there are no comments between the two nodes |
| Branch LogicalExpression | |
| ✓ Was returned | if (!options.disallowNewLine && token.loc.end.line !== nextToken.loc.start.line) { |
| ✓ Was returned | if (!options.disallowNewLine && token.loc.end.line !== nextToken.loc.start.line) { |
| Function (anonymous_78) | |
|---|---|
| ✓ Was called | var emitError = function(countPrefix, spaceCount) {··· if (fixed) { this._file.setWhitespaceBefore(nextToken, new Array(spaceCount + 1).join(' ')); } var msgPostfix = token.value + ' and ' + nextToken.value; if (!options.message) { if (exactly === 0) { // support noWhitespaceBetween options.message = 'Unexpected whitespace between ' + msgPostfix; } else if (exactly !== undefined) { // support whitespaceBetween (spaces option) options.message = spaceCount + ' spaces required between ' + msgPostfix; } else if (atLeast === 1 && atMost === undefined) { // support whitespaceBetween (no spaces option) options.message = 'Missing space between ' + msgPostfix; } else { options.message = countPrefix + ' ' + spaceCount + ' spaces required between ' + msgPostfix; } } this.emit('error', { message: options.message, line: token.loc.end.line, column: token.loc.end.column, fixed: fixed }); }.bind(this); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (fixed) {··· this._file.setWhitespaceBefore(nextToken, new Array(spaceCount + 1).join(' ')); } |
| ✓ Negative was executed (else) | }··· var msgPostfix = token.value + ' and ' + nextToken.value; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!options.message) {··· if (exactly === 0) { // support noWhitespaceBetween options.message = 'Unexpected whitespace between ' + msgPostfix; } else if (exactly !== undefined) { // support whitespaceBetween (spaces option) options.message = spaceCount + ' spaces required between ' + msgPostfix; } else if (atLeast === 1 && atMost === undefined) { // support whitespaceBetween (no spaces option) options.message = 'Missing space between ' + msgPostfix; } else { options.message = countPrefix + ' ' + spaceCount + ' spaces required between ' + msgPostfix; } } |
| ✓ Negative was executed (else) | }··· this.emit('error', { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (exactly === 0) {··· // support noWhitespaceBetween options.message = 'Unexpected whitespace between ' + msgPostfix; } else if (exactly !== undefined) { |
| ✓ Negative was executed (else) | } else if (exactly !== undefined) {··· // support whitespaceBetween (spaces option) options.message = spaceCount + ' spaces required between ' + msgPostfix; } else if (atLeast === 1 && atMost === undefined) { // support whitespaceBetween (no spaces option) options.message = 'Missing space between ' + msgPostfix; } else { options.message = countPrefix + ' ' + spaceCount + ' spaces required between ' + msgPostfix; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (exactly !== undefined) {··· // support whitespaceBetween (spaces option) options.message = spaceCount + ' spaces required between ' + msgPostfix; } else if (atLeast === 1 && atMost === undefined) { |
| ✓ Negative was executed (else) | } else if (atLeast === 1 && atMost === undefined) {··· // support whitespaceBetween (no spaces option) options.message = 'Missing space between ' + msgPostfix; } else { options.message = countPrefix + ' ' + spaceCount + ' spaces required between ' + msgPostfix; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (atLeast === 1 && atMost === undefined) {··· // support whitespaceBetween (no spaces option) options.message = 'Missing space between ' + msgPostfix; } else { |
| ✓ Negative was executed (else) | } else {··· options.message = countPrefix + ' ' + spaceCount + ' spaces required between ' + msgPostfix; } |
| Branch LogicalExpression | |
| ✓ Was returned | } else if (atLeast === 1 && atMost === undefined) { |
| ✓ Was returned | } else if (atLeast === 1 && atMost === undefined) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (atLeast !== undefined && spacesBetween < atLeast) {··· emitError('at least', atLeast); } else if (atMost !== undefined && spacesBetween > atMost) { |
| ✓ Negative was executed (else) | } else if (atMost !== undefined && spacesBetween > atMost) {··· emitError('at most', atMost); } else if (exactly !== undefined && spacesBetween !== exactly) { emitError('exactly', exactly); } |
| Branch LogicalExpression | |
| ✓ Was returned | if (atLeast !== undefined && spacesBetween < atLeast) { |
| ✓ Was returned | if (atLeast !== undefined && spacesBetween < atLeast) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (atMost !== undefined && spacesBetween > atMost) {··· emitError('at most', atMost); } else if (exactly !== undefined && spacesBetween !== exactly) { |
| ✓ Negative was executed (else) | } else if (exactly !== undefined && spacesBetween !== exactly) {··· emitError('exactly', exactly); } |
| Branch LogicalExpression | |
| ✓ Was returned | } else if (atMost !== undefined && spacesBetween > atMost) { |
| ✓ Was returned | } else if (atMost !== undefined && spacesBetween > atMost) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (exactly !== undefined && spacesBetween !== exactly) {··· emitError('exactly', exactly); } |
| ✓ Negative was executed (else) | }··· }; |
| Branch LogicalExpression | |
| ✓ Was returned | } else if (exactly !== undefined && spacesBetween !== exactly) { |
| ✓ Was returned | } else if (exactly !== undefined && spacesBetween !== exactly) { |
| Function (anonymous_79) | |
|---|---|
| ✓ Was called | TokenAssert.prototype.indentation = function(options) {··· var lineNumber = options.lineNumber; var actual = options.actual; var expected = options.expected; var indentChar = options.indentChar; if (actual === expected) { return; } if (!options.silent) { this.emit('error', { message: 'Expected indentation of ' + expected + ' characters', line: lineNumber, column: expected, fixed: true }); } var token = this._file.getFirstTokenOnLine(lineNumber, { includeComments: true }); var newWhitespace = (new Array(expected + 1)).join(indentChar); if (!token) { this._setEmptyLineIndentation(lineNumber, newWhitespace); return; } this._updateWhitespaceByLine(token, function(lines) { lines[lines.length - 1] = newWhitespace; return lines; }); if (token.isComment) { this._updateCommentWhitespace(token, indentChar, actual, expected); } }; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (actual === expected) {··· return; } |
| ✓ Negative was executed (else) | }··· if (!options.silent) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!options.silent) {··· this.emit('error', { message: 'Expected indentation of ' + expected + ' characters', line: lineNumber, column: expected, fixed: true }); } |
| ✓ Negative was executed (else) | }··· var token = this._file.getFirstTokenOnLine(lineNumber, { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!token) {··· this._setEmptyLineIndentation(lineNumber, newWhitespace); return; } |
| ✓ Negative was executed (else) | }··· this._updateWhitespaceByLine(token, function(lines) { |
| Function (anonymous_80) | |
|---|---|
| ✓ Was called | this._updateWhitespaceByLine(token, function(lines) {··· lines[lines.length - 1] = newWhitespace; return lines; }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (token.isComment) {··· this._updateCommentWhitespace(token, indentChar, actual, expected); } |
| ✓ Negative was executed (else) | }··· }; |
| Function (anonymous_81) | |
|---|---|
| ✓ Was called | TokenAssert.prototype._updateWhitespaceByLine = function(token, callback) {··· var lineBreak = this._file.getLineBreakStyle(); var lines = this._file.getWhitespaceBefore(token).split(/\r\n|\r|\n/); lines = callback(lines); this._file.setWhitespaceBefore(token, lines.join(lineBreak)); }; |
| Function (anonymous_82) | |
|---|---|
| ✓ Was called | TokenAssert.prototype._updateCommentWhitespace = function(token, indentChar, actual, expected) {··· var difference = expected - actual; var tokenLines = token.value.split(/\r\n|\r|\n/); var i = 1; if (difference >= 0) { var lineWhitespace = (new Array(difference + 1)).join(indentChar); for (; i < tokenLines.length; i++) { tokenLines[i] = tokenLines[i] === '' ? '' : lineWhitespace + tokenLines[i]; } } else { for (; i < tokenLines.length; i++) { tokenLines[i] = tokenLines[i].substring(-difference); } } token.value = tokenLines.join(this._file.getLineBreakStyle()); }; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (difference >= 0) {··· var lineWhitespace = (new Array(difference + 1)).join(indentChar); for (; i < tokenLines.length; i++) { tokenLines[i] = tokenLines[i] === '' ? '' : lineWhitespace + tokenLines[i]; } } else { |
| ✓ Negative was executed (else) | } else {··· for (; i < tokenLines.length; i++) { tokenLines[i] = tokenLines[i].substring(-difference); } } |
| Branch ConditionalExpression | |
|---|---|
| ✗ Positive was not returned (? ...) | tokenLines[i] = tokenLines[i] === '' ? '' : lineWhitespace + tokenLines[i]; |
| ✓ Negative was returned (: ...) | tokenLines[i] = tokenLines[i] === '' ? '' : lineWhitespace + tokenLines[i]; |
| Function (anonymous_83) | |
|---|---|
| ✓ Was called | TokenAssert.prototype._setEmptyLineIndentation = function(lineNumber, newWhitespace) {··· var token; do { token = this._file.getFirstTokenOnLine(++lineNumber, { includeComments: true }); } while (!token); this._updateWhitespaceByLine(token, function(lines) { if (lines[0] !== '') { lines[0] = newWhitespace; } for (var i = 1; i < lines.length; i++) { lines[i] = newWhitespace; } return lines; }); }; |
| Function (anonymous_84) | |
|---|---|
| ✓ Was called | this._updateWhitespaceByLine(token, function(lines) {··· if (lines[0] !== '') { lines[0] = newWhitespace; } for (var i = 1; i < lines.length; i++) { lines[i] = newWhitespace; } return lines; }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (lines[0] !== '') {··· lines[0] = newWhitespace; } |
| ✓ Negative was executed (else) | }··· for (var i = 1; i < lines.length; i++) { |
| Function (anonymous_85) | |
|---|---|
| ✓ Was called | TokenAssert.prototype.sameLine = function(options) {··· options.exactly = 0; this.linesBetween(options); }; |
| Function (anonymous_86) | |
|---|---|
| ✓ Was called | TokenAssert.prototype.differentLine = function(options) {··· options.atLeast = 1; this.linesBetween(options); }; |
| Function (anonymous_87) | |
|---|---|
| ✓ Was called | TokenAssert.prototype.linesBetween = function(options) {··· var token = options.token; var nextToken = options.nextToken; var atLeast = options.atLeast; var atMost = options.atMost; var exactly = options.exactly; if (!token || !nextToken) { return; } this._validateOptions(options); // Only attempt to remove or add lines if there are no comments between the two nodes // as this prevents accidentally moving a valid token onto a line comment ed line var fixed = this._file.getNextToken(options.token, { includeComments: true }) === nextToken; var linesBetween = Math.abs(token.loc.end.line - nextToken.loc.start.line); var emitError = function(countPrefix, lineCount) { var msgPrefix = token.value + ' and ' + nextToken.value; if (!options.message) { if (exactly === 0) { // support sameLine options.message = msgPrefix + ' should be on the same line'; } else if (atLeast === 1 && atMost === undefined) { // support differentLine options.message = msgPrefix + ' should be on different lines'; } else { // support linesBetween options.message = msgPrefix + ' should have ' + countPrefix + ' ' + lineCount + ' line(s) between them'; } } if (fixed) { this._augmentLineCount(options, lineCount); } this.emit('error', { message: options.message, line: token.loc.end.line, column: token.loc.end.column, fixed: fixed }); }.bind(this); if (atLeast !== undefined && linesBetween < atLeast) { emitError('at least', atLeast); } else if (atMost !== undefined && linesBetween > atMost) { emitError('at most', atMost); } else if (exactly !== undefined && linesBetween !== exactly) { emitError('exactly', exactly); } }; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!token || !nextToken) {··· return; } |
| ✓ Negative was executed (else) | }··· this._validateOptions(options); |
| Branch LogicalExpression | |
| ✓ Was returned | if (!token || !nextToken) { |
| ✓ Was returned | if (!token || !nextToken) { |
| Function (anonymous_88) | |
|---|---|
| ✓ Was called | var emitError = function(countPrefix, lineCount) {··· var msgPrefix = token.value + ' and ' + nextToken.value; if (!options.message) { if (exactly === 0) { // support sameLine options.message = msgPrefix + ' should be on the same line'; } else if (atLeast === 1 && atMost === undefined) { // support differentLine options.message = msgPrefix + ' should be on different lines'; } else { // support linesBetween options.message = msgPrefix + ' should have ' + countPrefix + ' ' + lineCount + ' line(s) between them'; } } if (fixed) { this._augmentLineCount(options, lineCount); } this.emit('error', { message: options.message, line: token.loc.end.line, column: token.loc.end.column, fixed: fixed }); }.bind(this); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!options.message) {··· if (exactly === 0) { // support sameLine options.message = msgPrefix + ' should be on the same line'; } else if (atLeast === 1 && atMost === undefined) { // support differentLine options.message = msgPrefix + ' should be on different lines'; } else { // support linesBetween options.message = msgPrefix + ' should have ' + countPrefix + ' ' + lineCount + ' line(s) between them'; } } |
| ✓ Negative was executed (else) | }··· if (fixed) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (exactly === 0) {··· // support sameLine options.message = msgPrefix + ' should be on the same line'; } else if (atLeast === 1 && atMost === undefined) { |
| ✓ Negative was executed (else) | } else if (atLeast === 1 && atMost === undefined) {··· // support differentLine options.message = msgPrefix + ' should be on different lines'; } else { // support linesBetween options.message = msgPrefix + ' should have ' + countPrefix + ' ' + lineCount + ' line(s) between them'; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (atLeast === 1 && atMost === undefined) {··· // support differentLine options.message = msgPrefix + ' should be on different lines'; } else { |
| ✓ Negative was executed (else) | } else {··· // support linesBetween options.message = msgPrefix + ' should have ' + countPrefix + ' ' + lineCount + ' line(s) between them'; } |
| Branch LogicalExpression | |
| ✓ Was returned | } else if (atLeast === 1 && atMost === undefined) { |
| ✓ Was returned | } else if (atLeast === 1 && atMost === undefined) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (fixed) {··· this._augmentLineCount(options, lineCount); } |
| ✓ Negative was executed (else) | }··· this.emit('error', { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (atLeast !== undefined && linesBetween < atLeast) {··· emitError('at least', atLeast); } else if (atMost !== undefined && linesBetween > atMost) { |
| ✓ Negative was executed (else) | } else if (atMost !== undefined && linesBetween > atMost) {··· emitError('at most', atMost); } else if (exactly !== undefined && linesBetween !== exactly) { emitError('exactly', exactly); } |
| Branch LogicalExpression | |
| ✓ Was returned | if (atLeast !== undefined && linesBetween < atLeast) { |
| ✓ Was returned | if (atLeast !== undefined && linesBetween < atLeast) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (atMost !== undefined && linesBetween > atMost) {··· emitError('at most', atMost); } else if (exactly !== undefined && linesBetween !== exactly) { |
| ✓ Negative was executed (else) | } else if (exactly !== undefined && linesBetween !== exactly) {··· emitError('exactly', exactly); } |
| Branch LogicalExpression | |
| ✓ Was returned | } else if (atMost !== undefined && linesBetween > atMost) { |
| ✓ Was returned | } else if (atMost !== undefined && linesBetween > atMost) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (exactly !== undefined && linesBetween !== exactly) {··· emitError('exactly', exactly); } |
| ✓ Negative was executed (else) | }··· }; |
| Branch LogicalExpression | |
| ✓ Was returned | } else if (exactly !== undefined && linesBetween !== exactly) { |
| ✓ Was returned | } else if (exactly !== undefined && linesBetween !== exactly) { |
| Function (anonymous_89) | |
|---|---|
| ✓ Was called | TokenAssert.prototype._validateOptions = function(options) {··· var token = options.token; var nextToken = options.nextToken; var atLeast = options.atLeast; var atMost = options.atMost; var exactly = options.exactly; if (token === nextToken) { throw new Error('You cannot specify the same token as both token and nextToken'); } if (atLeast === undefined && atMost === undefined && exactly === undefined) { throw new Error('You must specify at least one option'); } if (exactly !== undefined && (atLeast !== undefined || atMost !== undefined)) { throw new Error('You cannot specify atLeast or atMost with exactly'); } if (atLeast !== undefined && atMost !== undefined && atMost < atLeast) { throw new Error('atLeast and atMost are in conflict'); } }; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (token === nextToken) {··· throw new Error('You cannot specify the same token as both token and nextToken'); } |
| ✓ Negative was executed (else) | }··· if (atLeast === undefined && |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | exactly === undefined) {··· throw new Error('You must specify at least one option'); } |
| ✓ Negative was executed (else) | }··· if (exactly !== undefined && (atLeast !== undefined || atMost !== undefined)) { |
| Branch LogicalExpression | |
| ✓ Was returned | exactly === undefined) { |
| ✓ Was returned | if (atLeast === undefined &&··· atMost === undefined && |
| Branch LogicalExpression | |
| ✓ Was returned | atMost === undefined && |
| ✓ Was returned | if (atLeast === undefined && |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (exactly !== undefined && (atLeast !== undefined || atMost !== undefined)) {··· throw new Error('You cannot specify atLeast or atMost with exactly'); } |
| ✓ Negative was executed (else) | }··· if (atLeast !== undefined && atMost !== undefined && atMost < atLeast) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (exactly !== undefined && (atLeast !== undefined || atMost !== undefined)) { |
| ✓ Was returned | if (exactly !== undefined && (atLeast !== undefined || atMost !== undefined)) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (exactly !== undefined && (atLeast !== undefined || atMost !== undefined)) { |
| ✓ Was returned | if (exactly !== undefined && (atLeast !== undefined || atMost !== undefined)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (atLeast !== undefined && atMost !== undefined && atMost < atLeast) {··· throw new Error('atLeast and atMost are in conflict'); } |
| ✓ Negative was executed (else) | }··· }; |
| Branch LogicalExpression | |
| ✓ Was returned | if (atLeast !== undefined && atMost !== undefined && atMost < atLeast) { |
| ✓ Was returned | if (atLeast !== undefined && atMost !== undefined && atMost < atLeast) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (atLeast !== undefined && atMost !== undefined && atMost < atLeast) { |
| ✓ Was returned | if (atLeast !== undefined && atMost !== undefined && atMost < atLeast) { |
| Function (anonymous_90) | |
|---|---|
| ✓ Was called | TokenAssert.prototype._augmentLineCount = function(options, lineCount) {··· var token = options.nextToken; if (lineCount === 0) { if (options.stickToPreviousToken) { var nextToken = this._file.getNextToken(token, { includeComments: true }); this._file.setWhitespaceBefore(nextToken, this._file.getWhitespaceBefore(token)); } this._file.setWhitespaceBefore(token, ' '); return; } this._updateWhitespaceByLine(token, function(lines) { var currentLineCount = lines.length; var lastLine = lines[lines.length - 1]; if (currentLineCount <= lineCount) { // add additional lines that maintain the same indentation as the former last line for (; currentLineCount <= lineCount; currentLineCount++) { lines[lines.length - 1] = ''; lines.push(lastLine); } } else { // remove lines and then ensure that the new last line maintains the previous indentation lines = lines.slice(0, lineCount + 1); lines[lines.length - 1] = lastLine; } return lines; }); }; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (lineCount === 0) {··· if (options.stickToPreviousToken) { var nextToken = this._file.getNextToken(token, { includeComments: true }); this._file.setWhitespaceBefore(nextToken, this._file.getWhitespaceBefore(token)); } this._file.setWhitespaceBefore(token, ' '); return; } |
| ✓ Negative was executed (else) | }··· this._updateWhitespaceByLine(token, function(lines) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options.stickToPreviousToken) {··· var nextToken = this._file.getNextToken(token, { includeComments: true }); this._file.setWhitespaceBefore(nextToken, this._file.getWhitespaceBefore(token)); } |
| ✓ Negative was executed (else) | }··· this._file.setWhitespaceBefore(token, ' '); |
| Function (anonymous_91) | |
|---|---|
| ✓ Was called | this._updateWhitespaceByLine(token, function(lines) {··· var currentLineCount = lines.length; var lastLine = lines[lines.length - 1]; if (currentLineCount <= lineCount) { // add additional lines that maintain the same indentation as the former last line for (; currentLineCount <= lineCount; currentLineCount++) { lines[lines.length - 1] = ''; lines.push(lastLine); } } else { // remove lines and then ensure that the new last line maintains the previous indentation lines = lines.slice(0, lineCount + 1); lines[lines.length - 1] = lastLine; } return lines; }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (currentLineCount <= lineCount) {··· // add additional lines that maintain the same indentation as the former last line for (; currentLineCount <= lineCount; currentLineCount++) { lines[lines.length - 1] = ''; lines.push(lastLine); } } else { |
| ✓ Negative was executed (else) | } else {··· // remove lines and then ensure that the new last line maintains the previous indentation lines = lines.slice(0, lineCount + 1); lines[lines.length - 1] = lastLine; } |
| Function (anonymous_92) | |
|---|---|
| ✓ Was called | TokenAssert.prototype.tokenBefore = function(options) {··· var token = options.token; var actualTokenBefore = this._file.getPrevToken(token); var expectedTokenBefore = options.expectedTokenBefore; if (!actualTokenBefore) { this.emit('error', { message: expectedTokenBefore.value + ' was expected before ' + token.value + ' but document start found', line: token.loc.start.line, column: token.loc.start.column }); return; } // Only attempt to remove or add lines if there are no comments between the two nodes // as this prevents accidentally moving a valid token onto a line comment ed line var fixed = this._file.getPrevToken(options.token, {includeComments: true}) === actualTokenBefore; if ( actualTokenBefore.type !== expectedTokenBefore.type || actualTokenBefore.value !== expectedTokenBefore.value ) { if (fixed) { this._file.setWhitespaceBefore(token, expectedTokenBefore.value + this._file.getWhitespaceBefore(token)); } var message = options.message; if (!message) { var showTypes = expectedTokenBefore.value === actualTokenBefore.value; message = expectedTokenBefore.value + (showTypes ? ' (' + expectedTokenBefore.type + ')' : '') + ' was expected before ' + token.value + ' but ' + actualTokenBefore.value + (showTypes ? ' (' + actualTokenBefore.type + ')' : '') + ' found'; } this.emit('error', { message: message, line: actualTokenBefore.loc.end.line, column: actualTokenBefore.loc.end.column, fixed: fixed }); } }; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!actualTokenBefore) {··· this.emit('error', { message: expectedTokenBefore.value + ' was expected before ' + token.value + ' but document start found', line: token.loc.start.line, column: token.loc.start.column }); return; } |
| ✓ Negative was executed (else) | }··· // Only attempt to remove or add lines if there are no comments between the two nodes |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | ) {··· if (fixed) { this._file.setWhitespaceBefore(token, expectedTokenBefore.value + this._file.getWhitespaceBefore(token)); } var message = options.message; if (!message) { var showTypes = expectedTokenBefore.value === actualTokenBefore.value; message = expectedTokenBefore.value + (showTypes ? ' (' + expectedTokenBefore.type + ')' : '') + ' was expected before ' + token.value + ' but ' + actualTokenBefore.value + (showTypes ? ' (' + actualTokenBefore.type + ')' : '') + ' found'; } this.emit('error', { message: message, line: actualTokenBefore.loc.end.line, column: actualTokenBefore.loc.end.column, fixed: fixed }); } |
| ✓ Negative was executed (else) | }··· }; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | actualTokenBefore.value !== expectedTokenBefore.value |
| ✓ Was returned | actualTokenBefore.type !== expectedTokenBefore.type || |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (fixed) {··· this._file.setWhitespaceBefore(token, expectedTokenBefore.value + this._file.getWhitespaceBefore(token)); } |
| ✗ Negative was not executed (else) | }··· var message = options.message; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!message) {··· var showTypes = expectedTokenBefore.value === actualTokenBefore.value; message = expectedTokenBefore.value + (showTypes ? ' (' + expectedTokenBefore.type + ')' : '') + ' was expected before ' + token.value + ' but ' + actualTokenBefore.value + (showTypes ? ' (' + actualTokenBefore.type + ')' : '') + ' found'; } |
| ✓ Negative was executed (else) | }··· this.emit('error', { |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | expectedTokenBefore.value + (showTypes ? ' (' + expectedTokenBefore.type + ')' : '') + |
| ✓ Negative was returned (: ...) | expectedTokenBefore.value + (showTypes ? ' (' + expectedTokenBefore.type + ')' : '') + |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | ' but ' + actualTokenBefore.value + (showTypes ? ' (' + actualTokenBefore.type + ')' : '') + ' found'; |
| ✓ Negative was returned (: ...) | ' but ' + actualTokenBefore.value + (showTypes ? ' (' + actualTokenBefore.type + ')' : '') + ' found'; |
| Function (anonymous_93) | |
|---|---|
| ✓ Was called | TokenAssert.prototype.noTokenBefore = function(options) {··· var token = options.token; var actualTokenBefore = this._file.getPrevToken(token); if (!actualTokenBefore) { // document start return; } var fixed = this._file.getPrevToken(options.token, { includeComments: true }) === actualTokenBefore; var expectedTokenBefore = options.expectedTokenBefore; if (actualTokenBefore.type === expectedTokenBefore.type && actualTokenBefore.value === expectedTokenBefore.value ) { if (fixed) { actualTokenBefore.value = ''; } this.emit('error', { message: options.message || 'Illegal ' + expectedTokenBefore.value + ' was found before ' + token.value, line: actualTokenBefore.loc.end.line, column: actualTokenBefore.loc.end.column, fixed: fixed }); } }; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!actualTokenBefore) {··· // document start return; } |
| ✓ Negative was executed (else) | }··· var fixed = this._file.getPrevToken(options.token, { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | ) {··· if (fixed) { actualTokenBefore.value = ''; } this.emit('error', { message: options.message || 'Illegal ' + expectedTokenBefore.value + ' was found before ' + token.value, line: actualTokenBefore.loc.end.line, column: actualTokenBefore.loc.end.column, fixed: fixed }); } |
| ✓ Negative was executed (else) | }··· }; |
| Branch LogicalExpression | |
| ✓ Was returned | actualTokenBefore.value === expectedTokenBefore.value |
| ✓ Was returned | if (actualTokenBefore.type === expectedTokenBefore.type && |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (fixed) {··· actualTokenBefore.value = ''; } |
| ✗ Negative was not executed (else) | }··· this.emit('error', { |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | message: options.message || 'Illegal ' + expectedTokenBefore.value + ' was found before ' + token.value, |
| ✓ Was returned | message: options.message || 'Illegal ' + expectedTokenBefore.value + ' was found before ' + token.value, |
| Function (anonymous_94) | |
|---|---|
| ✓ Was called | var JsFile = function(params) {··· params = params || {}; this._parseErrors = []; this._filename = params.filename; this._source = params.source; this._tree = {tokens: [], comments: []}; this._es3 = params.es3 || false; this._es6 = params.es6 || false; this._lineBreaks = null; this._lines = this._source.split(/\r\n|\r|\n/); var hasErrors = false; try { this._tree = parseJavaScriptSource(this._source, params.esprima, params.esprimaOptions); } catch (e) { hasErrors = true; this._parseErrors.push(e); } // Lazy initialization this._scope = null; this._tokens = this._buildTokenList(this._tree.tokens, this._tree.comments); this._addEOFToken(hasErrors); this._tokens = this._addWhitespaceTokens(this._tokens, this._source); this._setTokenIndexes(); var nodeIndexes = this._buildNodeIndex(); this._index = nodeIndexes.nodesByType; this._nodesByStartRange = nodeIndexes.nodesByStartRange; this._fixEsprimaIdentifiers(); this._buildDisabledRuleIndex(); }; |
| Branch LogicalExpression | |
|---|---|
| ✗ Was not returned | params = params || {}; |
| ✓ Was returned | params = params || {}; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | this._es3 = params.es3 || false; |
| ✓ Was returned | this._es3 = params.es3 || false; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | this._es6 = params.es6 || false; |
| ✓ Was returned | this._es6 = params.es6 || false; |
| Function (anonymous_95) | |
|---|---|
| ✓ Was called | getLineBreakStyle: function() {··· var lineBreaks = this.getLineBreaks(); return lineBreaks.length ? lineBreaks[0] : '\n'; }, |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | return lineBreaks.length ? lineBreaks[0] : '\n'; |
| ✓ Negative was returned (: ...) | return lineBreaks.length ? lineBreaks[0] : '\n'; |
| Function (anonymous_96) | |
|---|---|
| ✓ Was called | getLineBreaks: function() {··· if (this._lineBreaks === null) { this._lineBreaks = this._source.match(/\r\n|\r|\n/g) || []; } return this._lineBreaks; }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._lineBreaks === null) {··· this._lineBreaks = this._source.match(/\r\n|\r|\n/g) || []; } |
| ✓ Negative was executed (else) | }··· return this._lineBreaks; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | this._lineBreaks = this._source.match(/\r\n|\r|\n/g) || []; |
| ✓ Was returned | this._lineBreaks = this._source.match(/\r\n|\r|\n/g) || []; |
| Function (anonymous_97) | |
|---|---|
| ✓ Was called | _setTokenIndexes: function() {··· var tokenIndexes = this._buildTokenIndex(this._tokens); this._tokenRangeStartIndex = tokenIndexes.tokenRangeStartIndex; this._tokenRangeEndIndex = tokenIndexes.tokenRangeEndIndex; this._tokensByLineIndex = tokenIndexes.tokensByLineIndex; }, |
| Function (anonymous_98) | |
|---|---|
| ✓ Was called | _buildDisabledRuleIndex: function() {··· this._disabledRuleIndex = []; var comments = this.getComments(); // Matches a comment enabling or disabling rules. var blockRe = /(jscs\s*:\s*(en|dis)able)(.*)/; // Matches a comment disbling a rule for one line. var lineRe = /(jscs\s*:\s*ignore)(.*)/; comments.forEach(function(comment) { var enabled; var value = comment.value.trim(); var blockParsed = blockRe.exec(value); var lineParsed = lineRe.exec(value); var line = comment.loc.start.line; if (blockParsed && blockParsed.index === 0) { enabled = blockParsed[2] === 'en'; this._addToDisabledRuleIndex(enabled, blockParsed[3], line); } else if (lineParsed && lineParsed.index === 0) { this._disableRulesAt(lineParsed[2], line); } }, this); }, |
| Function (anonymous_99) | |
|---|---|
| ✓ Was called | comments.forEach(function(comment) {··· var enabled; var value = comment.value.trim(); var blockParsed = blockRe.exec(value); var lineParsed = lineRe.exec(value); var line = comment.loc.start.line; if (blockParsed && blockParsed.index === 0) { enabled = blockParsed[2] === 'en'; this._addToDisabledRuleIndex(enabled, blockParsed[3], line); } else if (lineParsed && lineParsed.index === 0) { this._disableRulesAt(lineParsed[2], line); } }, this); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (blockParsed && blockParsed.index === 0) {··· enabled = blockParsed[2] === 'en'; this._addToDisabledRuleIndex(enabled, blockParsed[3], line); } else if (lineParsed && lineParsed.index === 0) { |
| ✓ Negative was executed (else) | } else if (lineParsed && lineParsed.index === 0) {··· this._disableRulesAt(lineParsed[2], line); } |
| Branch LogicalExpression | |
| ✓ Was returned | if (blockParsed && blockParsed.index === 0) { |
| ✓ Was returned | if (blockParsed && blockParsed.index === 0) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (lineParsed && lineParsed.index === 0) {··· this._disableRulesAt(lineParsed[2], line); } |
| ✓ Negative was executed (else) | }··· }, this); |
| Branch LogicalExpression | |
| ✓ Was returned | } else if (lineParsed && lineParsed.index === 0) { |
| ✓ Was returned | } else if (lineParsed && lineParsed.index === 0) { |
| Function (anonymous_100) | |
|---|---|
| ✓ Was called | setWhitespaceBefore: function(token, whitespace) {··· var whitespaceToken = this.getPrevToken(token, {includeWhitespace: true}); if (whitespaceToken && whitespaceToken.type === 'Whitespace') { // Modifying already existing token. if (whitespace === '') { this.removeToken(whitespaceToken); } else { whitespaceToken.value = whitespace; } } else if (whitespace !== '') { var tokenIndex = token._tokenIndex; // Adding a token before specified one. this._tokens.splice(tokenIndex, 0, { type: 'Whitespace', value: whitespace, isWhitespace: true }); // Quickly updating modified token order for (var i = tokenIndex; i < this._tokens.length; i++) { this._tokens[i]._tokenIndex = i; } } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (whitespaceToken && whitespaceToken.type === 'Whitespace') {··· // Modifying already existing token. if (whitespace === '') { this.removeToken(whitespaceToken); } else { whitespaceToken.value = whitespace; } } else if (whitespace !== '') { |
| ✓ Negative was executed (else) | } else if (whitespace !== '') {··· var tokenIndex = token._tokenIndex; // Adding a token before specified one. this._tokens.splice(tokenIndex, 0, { type: 'Whitespace', value: whitespace, isWhitespace: true }); // Quickly updating modified token order for (var i = tokenIndex; i < this._tokens.length; i++) { this._tokens[i]._tokenIndex = i; } } |
| Branch LogicalExpression | |
| ✓ Was returned | if (whitespaceToken && whitespaceToken.type === 'Whitespace') { |
| ✓ Was returned | if (whitespaceToken && whitespaceToken.type === 'Whitespace') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (whitespace === '') {··· this.removeToken(whitespaceToken); } else { |
| ✓ Negative was executed (else) | } else {··· whitespaceToken.value = whitespace; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (whitespace !== '') {··· var tokenIndex = token._tokenIndex; // Adding a token before specified one. this._tokens.splice(tokenIndex, 0, { type: 'Whitespace', value: whitespace, isWhitespace: true }); // Quickly updating modified token order for (var i = tokenIndex; i < this._tokens.length; i++) { this._tokens[i]._tokenIndex = i; } } |
| ✓ Negative was executed (else) | }··· }, |
| Function (anonymous_101) | |
|---|---|
| ✓ Was called | getWhitespaceBefore: function(token) {··· var whitespaceToken = this.getPrevToken(token, {includeWhitespace: true}); if (whitespaceToken && whitespaceToken.type === 'Whitespace') { return whitespaceToken.value; } else { return ''; } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (whitespaceToken && whitespaceToken.type === 'Whitespace') {··· return whitespaceToken.value; } else { |
| ✓ Negative was executed (else) | } else {··· return ''; } |
| Branch LogicalExpression | |
| ✓ Was returned | if (whitespaceToken && whitespaceToken.type === 'Whitespace') { |
| ✓ Was returned | if (whitespaceToken && whitespaceToken.type === 'Whitespace') { |
| Function (anonymous_102) | |
|---|---|
| ✓ Was called | removeEntity: function(entities, entity) {··· for (var i = 0; i < entities.length; i++) { if (entities[i] === entity) { entities.splice(i, 1); return; } } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (entities[i] === entity) {··· entities.splice(i, 1); return; } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_103) | |
|---|---|
| ✓ Was called | removeToken: function(token) {··· this.removeEntity(this._tokens, token); this._setTokenIndexes(); }, |
| Function (anonymous_104) | |
|---|---|
| ✓ Was called | _disableRulesAt: function(rules, line) {··· rules = rules.split(/\s*,\s*/); for (var i = 0; i < rules.length; i++) { if (!this.isEnabledRule(rules[i], line)) { continue; } this._addToDisabledRuleIndex(false, rules[i], line); this._addToDisabledRuleIndex(true, rules[i], line + 1); } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!this.isEnabledRule(rules[i], line)) {··· continue; } |
| ✓ Negative was executed (else) | }··· this._addToDisabledRuleIndex(false, rules[i], line); |
| Function (anonymous_105) | |
|---|---|
| ✓ Was called | isEnabledRule: function(ruleName, line) {··· var enabled = true; ruleName = ruleName.trim(); this._disabledRuleIndex.some(function(region) { // once the comment we're inspecting occurs after the location of the error, // no longer check for whether the state is enabled or disable if (region.line > line) { return true; } if (region.rule === ruleName || region.rule === '*') { enabled = region.enabled; } }, this); return enabled; }, |
| Function (anonymous_106) | |
|---|---|
| ✓ Was called | this._disabledRuleIndex.some(function(region) {··· // once the comment we're inspecting occurs after the location of the error, // no longer check for whether the state is enabled or disable if (region.line > line) { return true; } if (region.rule === ruleName || region.rule === '*') { enabled = region.enabled; } }, this); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (region.line > line) {··· return true; } |
| ✓ Negative was executed (else) | }··· if (region.rule === ruleName || region.rule === '*') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (region.rule === ruleName || region.rule === '*') {··· enabled = region.enabled; } |
| ✓ Negative was executed (else) | }··· }, this); |
| Branch LogicalExpression | |
| ✓ Was returned | if (region.rule === ruleName || region.rule === '*') { |
| ✓ Was returned | if (region.rule === ruleName || region.rule === '*') { |
| Function (anonymous_107) | |
|---|---|
| ✓ Was called | _addToDisabledRuleIndex: function(enabled, rulesStr, line) {··· rulesStr = rulesStr || '*'; rulesStr.split(',').forEach(function(rule) { rule = rule.trim(); if (!rule) { return; } this._disabledRuleIndex.push({ rule: rule, enabled: enabled, line: line }); }, this); }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | rulesStr = rulesStr || '*'; |
| ✓ Was returned | rulesStr = rulesStr || '*'; |
| Function (anonymous_108) | |
|---|---|
| ✓ Was called | rulesStr.split(',').forEach(function(rule) {··· rule = rule.trim(); if (!rule) { return; } this._disabledRuleIndex.push({ rule: rule, enabled: enabled, line: line }); }, this); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!rule) {··· return; } |
| ✓ Negative was executed (else) | }··· this._disabledRuleIndex.push({ |
| Function (anonymous_109) | |
|---|---|
| ✓ Was called | _buildTokenIndex: function(tokens) {··· var tokenRangeStartIndex = {}; var tokenRangeEndIndex = {}; var tokensByLineIndex = {}; for (var i = 0, l = tokens.length; i < l; i++) { var token = tokens[i]; token._tokenIndex = i; if (token.type === 'Whitespace') { continue; } // tokens by range tokenRangeStartIndex[token.range[0]] = token; tokenRangeEndIndex[token.range[1]] = token; // tokens by line var lineNumber = token.loc.start.line; if (!tokensByLineIndex[lineNumber]) { tokensByLineIndex[lineNumber] = []; } tokensByLineIndex[lineNumber].push(token); } return { tokenRangeStartIndex: tokenRangeStartIndex, tokenRangeEndIndex: tokenRangeEndIndex, tokensByLineIndex: tokensByLineIndex }; }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (token.type === 'Whitespace') {··· continue; } |
| ✓ Negative was executed (else) | }··· // tokens by range |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!tokensByLineIndex[lineNumber]) {··· tokensByLineIndex[lineNumber] = []; } |
| ✓ Negative was executed (else) | }··· tokensByLineIndex[lineNumber].push(token); |
| Function (anonymous_110) | |
|---|---|
| ✓ Was called | getTokenByRangeStart: function(start) {··· return this._tokenRangeStartIndex[start] || null; }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | return this._tokenRangeStartIndex[start] || null; |
| ✓ Was returned | return this._tokenRangeStartIndex[start] || null; |
| Function (anonymous_111) | |
|---|---|
| ✓ Was called | getTokenByRangeEnd: function(end) {··· return this._tokenRangeEndIndex[end] || null; }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | return this._tokenRangeEndIndex[end] || null; |
| ✓ Was returned | return this._tokenRangeEndIndex[end] || null; |
| Function (anonymous_112) | |
|---|---|
| ✓ Was called | getFirstNodeToken: function(node) {··· return this.getTokenByRangeStart(node.range[0]); }, |
| Function (anonymous_113) | |
|---|---|
| ✓ Was called | getLastNodeToken: function(node) {··· return this.getTokenByRangeEnd(node.range[1]); }, |
| Function (anonymous_114) | |
|---|---|
| ✓ Was called | getFirstToken: function(options) {··· return this._getTokenFromIndex(0, 1, options); }, |
| Function (anonymous_115) | |
|---|---|
| ✓ Was called | getLastToken: function(options) {··· return this._getTokenFromIndex(this._tokens.length - 1, -1, options); }, |
| Function (anonymous_116) | |
|---|---|
| ✓ Was called | _getTokenFromIndex: function(index, direction, options) {··· while (true) { var followingToken = this._tokens[index]; if (!followingToken) { return null; } if ( (!followingToken.isComment || (options && options.includeComments)) && (!followingToken.isWhitespace || (options && options.includeWhitespace)) ) { return followingToken; } index += direction; } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!followingToken) {··· return null; } |
| ✓ Negative was executed (else) | }··· if ( |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | ) {··· return followingToken; } |
| ✓ Negative was executed (else) | }··· index += direction; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | (!followingToken.isWhitespace || (options && options.includeWhitespace)) |
| ✓ Was returned | (!followingToken.isComment || (options && options.includeComments)) && |
| Branch LogicalExpression | |
| ✓ Was returned | (!followingToken.isComment || (options && options.includeComments)) && |
| ✓ Was returned | (!followingToken.isComment || (options && options.includeComments)) && |
| Branch LogicalExpression | |
| ✓ Was returned | (!followingToken.isComment || (options && options.includeComments)) && |
| ✗ Was not returned | (!followingToken.isComment || (options && options.includeComments)) && |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | (!followingToken.isWhitespace || (options && options.includeWhitespace)) |
| ✓ Was returned | (!followingToken.isWhitespace || (options && options.includeWhitespace)) |
| Branch LogicalExpression | |
| ✓ Was returned | (!followingToken.isWhitespace || (options && options.includeWhitespace)) |
| ✓ Was returned | (!followingToken.isWhitespace || (options && options.includeWhitespace)) |
| Function (anonymous_117) | |
|---|---|
| ✓ Was called | getPrevToken: function(token, options) {··· return this._getTokenFromIndex(token._tokenIndex - 1, -1, options); }, |
| Function (anonymous_118) | |
|---|---|
| ✓ Was called | getNextToken: function(token, options) {··· return this._getTokenFromIndex(token._tokenIndex + 1, 1, options); }, |
| Function (anonymous_119) | |
|---|---|
| ✓ Was called | findPrevToken: function(token, type, value) {··· var prevToken = this.getPrevToken(token); while (prevToken) { if (prevToken.type === type && (value === undefined || prevToken.value === value)) { return prevToken; } prevToken = this.getPrevToken(prevToken); } return prevToken; }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (prevToken.type === type && (value === undefined || prevToken.value === value)) {··· return prevToken; } |
| ✓ Negative was executed (else) | }··· prevToken = this.getPrevToken(prevToken); |
| Branch LogicalExpression | |
| ✓ Was returned | if (prevToken.type === type && (value === undefined || prevToken.value === value)) { |
| ✓ Was returned | if (prevToken.type === type && (value === undefined || prevToken.value === value)) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (prevToken.type === type && (value === undefined || prevToken.value === value)) { |
| ✓ Was returned | if (prevToken.type === type && (value === undefined || prevToken.value === value)) { |
| Function (anonymous_120) | |
|---|---|
| ✓ Was called | findNextToken: function(token, type, value) {··· var nextToken = this.getNextToken(token); while (nextToken) { if (nextToken.type === type && (value === undefined || nextToken.value === value)) { return nextToken; } nextToken = this.getNextToken(nextToken); } return nextToken; }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (nextToken.type === type && (value === undefined || nextToken.value === value)) {··· return nextToken; } |
| ✓ Negative was executed (else) | }··· nextToken = this.getNextToken(nextToken); |
| Branch LogicalExpression | |
| ✓ Was returned | if (nextToken.type === type && (value === undefined || nextToken.value === value)) { |
| ✓ Was returned | if (nextToken.type === type && (value === undefined || nextToken.value === value)) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (nextToken.type === type && (value === undefined || nextToken.value === value)) { |
| ✓ Was returned | if (nextToken.type === type && (value === undefined || nextToken.value === value)) { |
| Function (anonymous_121) | |
|---|---|
| ✓ Was called | findPrevOperatorToken: function(token, value) {··· return this.findPrevToken(token, value in KEYWORD_OPERATORS ? 'Keyword' : 'Punctuator', value); }, |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | return this.findPrevToken(token, value in KEYWORD_OPERATORS ? 'Keyword' : 'Punctuator', value); |
| ✓ Negative was returned (: ...) | return this.findPrevToken(token, value in KEYWORD_OPERATORS ? 'Keyword' : 'Punctuator', value); |
| Function (anonymous_122) | |
|---|---|
| ✓ Was called | findNextOperatorToken: function(token, value) {··· return this.findNextToken(token, value in KEYWORD_OPERATORS ? 'Keyword' : 'Punctuator', value); }, |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | return this.findNextToken(token, value in KEYWORD_OPERATORS ? 'Keyword' : 'Punctuator', value); |
| ✓ Negative was returned (: ...) | return this.findNextToken(token, value in KEYWORD_OPERATORS ? 'Keyword' : 'Punctuator', value); |
| Function (anonymous_123) | |
|---|---|
| ✓ Was called | iterate: function(cb, tree) {··· return treeIterator.iterate(tree || this._tree, cb); }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | return treeIterator.iterate(tree || this._tree, cb); |
| ✓ Was returned | return treeIterator.iterate(tree || this._tree, cb); |
| Function (anonymous_124) | |
|---|---|
| ✓ Was called | getNodeByRange: function(number) {··· assert(typeof number === 'number', 'requires node range argument'); var result = {}; // Look backwards for the first node(s) spanning `number` // (possible with this.iterate, but too slow on large files) var i = number; var nodes; do { // Escape hatch if (i < 0) { return result; } nodes = this._nodesByStartRange[i]; i--; } while (!nodes || nodes[0].range[1] <= number); // Return the deepest such node for (i = nodes.length - 1; i >= 0; i--) { if (nodes[i].range[1] > number) { return nodes[i]; } } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (i < 0) {··· return result; } |
| ✓ Negative was executed (else) | }··· nodes = this._nodesByStartRange[i]; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | } while (!nodes || nodes[0].range[1] <= number); |
| ✓ Was returned | } while (!nodes || nodes[0].range[1] <= number); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (nodes[i].range[1] > number) {··· return nodes[i]; } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_125) | |
|---|---|
| ✓ Was called | getNodesByFirstToken: function(token) {··· var result = []; if (token && token.range && token.range[0] >= 0) { var nodes = this._nodesByStartRange[token.range[0]]; if (nodes) { result = result.concat(nodes); } } return result; }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (token && token.range && token.range[0] >= 0) {··· var nodes = this._nodesByStartRange[token.range[0]]; if (nodes) { result = result.concat(nodes); } } |
| ✓ Negative was executed (else) | }··· return result; |
| Branch LogicalExpression | |
| ✓ Was returned | if (token && token.range && token.range[0] >= 0) { |
| ✓ Was returned | if (token && token.range && token.range[0] >= 0) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (token && token.range && token.range[0] >= 0) { |
| ✓ Was returned | if (token && token.range && token.range[0] >= 0) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (nodes) {··· result = result.concat(nodes); } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_126) | |
|---|---|
| ✓ Was called | getNodesByType: function(type) {··· if (typeof type === 'string') { return this._index[type] || []; } else { var result = []; for (var i = 0, l = type.length; i < l; i++) { var nodes = this._index[type[i]]; if (nodes) { result = result.concat(nodes); } } return result; } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof type === 'string') {··· return this._index[type] || []; } else { |
| ✓ Negative was executed (else) | } else {··· var result = []; for (var i = 0, l = type.length; i < l; i++) { var nodes = this._index[type[i]]; if (nodes) { result = result.concat(nodes); } } return result; } |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | return this._index[type] || []; |
| ✓ Was returned | return this._index[type] || []; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (nodes) {··· result = result.concat(nodes); } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_127) | |
|---|---|
| ✓ Was called | iterateNodesByType: function(type, cb, context) {··· return this.getNodesByType(type).forEach(cb, context || this); }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | return this.getNodesByType(type).forEach(cb, context || this); |
| ✗ Was not returned | return this.getNodesByType(type).forEach(cb, context || this); |
| Function (anonymous_128) | |
|---|---|
| ✓ Was called | iterateTokensByType: function(type, cb) {··· var types = (typeof type === 'string') ? [type] : type; var typeIndex = {}; types.forEach(function(type) { typeIndex[type] = true; }); this._forEachToken(function(token, index, tokens) { if (typeIndex[token.type]) { cb(token, index, tokens); } }); }, |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | var types = (typeof type === 'string') ? [type] : type; |
| ✓ Negative was returned (: ...) | var types = (typeof type === 'string') ? [type] : type; |
| Function (anonymous_129) | |
|---|---|
| ✓ Was called | types.forEach(function(type) {··· typeIndex[type] = true; }); |
| Function (anonymous_130) | |
|---|---|
| ✓ Was called | this._forEachToken(function(token, index, tokens) {··· if (typeIndex[token.type]) { cb(token, index, tokens); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeIndex[token.type]) {··· cb(token, index, tokens); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_131) | |
|---|---|
| ✓ Was called | iterateTokenByValue: function(name, cb) {··· var names = (typeof name === 'string') ? [name] : name; var nameIndex = {}; names.forEach(function(type) { nameIndex[type] = true; }); this._forEachToken(function(token, index, tokens) { if (nameIndex.hasOwnProperty(token.value)) { cb(token, index, tokens); } }); }, |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | var names = (typeof name === 'string') ? [name] : name; |
| ✓ Negative was returned (: ...) | var names = (typeof name === 'string') ? [name] : name; |
| Function (anonymous_132) | |
|---|---|
| ✓ Was called | names.forEach(function(type) {··· nameIndex[type] = true; }); |
| Function (anonymous_133) | |
|---|---|
| ✓ Was called | this._forEachToken(function(token, index, tokens) {··· if (nameIndex.hasOwnProperty(token.value)) { cb(token, index, tokens); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (nameIndex.hasOwnProperty(token.value)) {··· cb(token, index, tokens); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_134) | |
|---|---|
| ✓ Was called | _forEachToken: function(cb) {··· var index = 0; var tokens = this._tokens; while (index < tokens.length) { var token = tokens[index]; cb(token, index, tokens); index = token._tokenIndex; index++; } }, |
| Function (anonymous_135) | |
|---|---|
| ✓ Was called | iterateTokensByTypeAndValue: function(type, value, cb) {··· var values = (typeof value === 'string') ? [value] : value; var valueIndex = {}; values.forEach(function(type) { valueIndex[type] = true; }); this._forEachToken(function(token, index, tokens) { if (token.type === type && valueIndex[token.value]) { cb(token, index, tokens); } }); }, |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | var values = (typeof value === 'string') ? [value] : value; |
| ✓ Negative was returned (: ...) | var values = (typeof value === 'string') ? [value] : value; |
| Function (anonymous_136) | |
|---|---|
| ✓ Was called | values.forEach(function(type) {··· valueIndex[type] = true; }); |
| Function (anonymous_137) | |
|---|---|
| ✓ Was called | this._forEachToken(function(token, index, tokens) {··· if (token.type === type && valueIndex[token.value]) { cb(token, index, tokens); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (token.type === type && valueIndex[token.value]) {··· cb(token, index, tokens); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | if (token.type === type && valueIndex[token.value]) { |
| ✓ Was returned | if (token.type === type && valueIndex[token.value]) { |
| Function (anonymous_138) | |
|---|---|
| ✓ Was called | getFirstTokenOnLine: function(lineNumber, options) {··· var tokensByLine = this._tokensByLineIndex[lineNumber]; if (!tokensByLine) { return null; } if (options && options.includeComments) { return tokensByLine[0]; } for (var i = 0; i < tokensByLine.length; i++) { var token = tokensByLine[i]; if (!token.isComment) { return token; } } return null; }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!tokensByLine) {··· return null; } |
| ✓ Negative was executed (else) | }··· if (options && options.includeComments) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options && options.includeComments) {··· return tokensByLine[0]; } |
| ✓ Negative was executed (else) | }··· for (var i = 0; i < tokensByLine.length; i++) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (options && options.includeComments) { |
| ✓ Was returned | if (options && options.includeComments) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!token.isComment) {··· return token; } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_139) | |
|---|---|
| ✓ Was called | getLastTokenOnLine: function(lineNumber, options) {··· var tokensByLine = this._tokensByLineIndex[lineNumber]; if (!tokensByLine) { return null; } if (options && options.includeComments) { return tokensByLine[tokensByLine.length - 1]; } for (var i = tokensByLine.length - 1; i >= 0; i--) { var token = tokensByLine[i]; if (!token.isComment) { return token; } } return null; }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!tokensByLine) {··· return null; } |
| ✓ Negative was executed (else) | }··· if (options && options.includeComments) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options && options.includeComments) {··· return tokensByLine[tokensByLine.length - 1]; } |
| ✓ Negative was executed (else) | }··· for (var i = tokensByLine.length - 1; i >= 0; i--) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (options && options.includeComments) { |
| ✓ Was returned | if (options && options.includeComments) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!token.isComment) {··· return token; } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_140) | |
|---|---|
| ✓ Was called | getDialect: function() {··· if (this._es6) { return 'es6'; } if (this._es3) { return 'es3'; } return 'es5'; }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._es6) {··· return 'es6'; } |
| ✓ Negative was executed (else) | }··· if (this._es3) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._es3) {··· return 'es3'; } |
| ✓ Negative was executed (else) | }··· return 'es5'; |
| Function (anonymous_141) | |
|---|---|
| ✓ Was called | getSource: function() {··· return this._source; }, |
| Function (anonymous_142) | |
|---|---|
| ✓ Was called | getTree: function() {··· return this._tree; }, |
| Function (anonymous_143) | |
|---|---|
| ✓ Was called | getTokens: function() {··· return this._tokens; }, |
| Function (anonymous_144) | |
|---|---|
| ✗ Was not called | setTokens: function(tokens) {··· this._tokens = tokens; }, |
| Function (anonymous_145) | |
|---|---|
| ✓ Was called | getComments: function() {··· return this._tree.comments; }, |
| Function (anonymous_146) | |
|---|---|
| ✓ Was called | getFilename: function() {··· return this._filename; }, |
| Function (anonymous_147) | |
|---|---|
| ✓ Was called | getLines: function() {··· return this._lines; }, |
| Function (anonymous_148) | |
|---|---|
| ✓ Was called | getScope: function() {··· if (!this._scope) { this._scope = escope.analyze(this._tree, { ecmaVersion: 6, ignoreEval: true, sourceType: 'module' }); } return this._scope; }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!this._scope) {··· this._scope = escope.analyze(this._tree, { ecmaVersion: 6, ignoreEval: true, sourceType: 'module' }); } |
| ✗ Negative was not executed (else) | }··· return this._scope; |
| Function (anonymous_149) | |
|---|---|
| ✓ Was called | getLinesWithCommentsRemoved: function() {··· var lines = this.getLines().concat(); this.getComments().concat().reverse().forEach(function(comment) { var startLine = comment.loc.start.line; var startCol = comment.loc.start.column; var endLine = comment.loc.end.line; var endCol = comment.loc.end.column; var i = startLine - 1; if (startLine === endLine) { // Remove tralling spaces (see gh-1968) lines[i] = lines[i].replace(/\*\/\s+/, '\*\/'); lines[i] = lines[i].substring(0, startCol) + lines[i].substring(endCol); } else { lines[i] = lines[i].substring(0, startCol); for (var x = i + 1; x < endLine - 1; x++) { lines[x] = ''; } lines[x] = lines[x].substring(endCol); } }); return lines; }, |
| Function (anonymous_150) | |
|---|---|
| ✓ Was called | this.getComments().concat().reverse().forEach(function(comment) {··· var startLine = comment.loc.start.line; var startCol = comment.loc.start.column; var endLine = comment.loc.end.line; var endCol = comment.loc.end.column; var i = startLine - 1; if (startLine === endLine) { // Remove tralling spaces (see gh-1968) lines[i] = lines[i].replace(/\*\/\s+/, '\*\/'); lines[i] = lines[i].substring(0, startCol) + lines[i].substring(endCol); } else { lines[i] = lines[i].substring(0, startCol); for (var x = i + 1; x < endLine - 1; x++) { lines[x] = ''; } lines[x] = lines[x].substring(endCol); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (startLine === endLine) {··· // Remove tralling spaces (see gh-1968) lines[i] = lines[i].replace(/\*\/\s+/, '\*\/'); lines[i] = lines[i].substring(0, startCol) + lines[i].substring(endCol); } else { |
| ✓ Negative was executed (else) | } else {··· lines[i] = lines[i].substring(0, startCol); for (var x = i + 1; x < endLine - 1; x++) { lines[x] = ''; } lines[x] = lines[x].substring(endCol); } |
| Function (anonymous_151) | |
|---|---|
| ✓ Was called | render: function() {··· var result = ''; // For-loop for maximal speed. for (var i = 0; i < this._tokens.length; i++) { var token = this._tokens[i]; switch (token.type) { // Line-comment: // ... case 'Line': result += '//' + token.value; break; // Block-comment: /* ... */ case 'Block': result += '/*' + token.value + '*/'; break; default: result += token.value; } } return result; }, |
| Branch SwitchStatement | |
|---|---|
| ✓ Was evaluated | case 'Line':··· result += '//' + token.value; break; |
| ✓ Was evaluated | case 'Block':··· result += '/*' + token.value + '*/'; break; |
| ✓ Was evaluated | default:··· result += token.value; |
| Function (anonymous_152) | |
|---|---|
| ✓ Was called | getParseErrors: function() {··· return this._parseErrors; }, |
| Function (anonymous_153) | |
|---|---|
| ✓ Was called | _buildTokenList: function(codeTokens, commentTokens) {··· var result = []; var codeQueue = codeTokens.concat(); var commentQueue = commentTokens.concat(); while (codeQueue.length > 0 || commentQueue.length > 0) { if (codeQueue.length > 0 && (!commentQueue.length || commentQueue[0].range[0] > codeQueue[0].range[0])) { result.push(codeQueue.shift()); } else { var commentToken = commentQueue.shift(); commentToken.isComment = true; result.push(commentToken); } } return result; }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | while (codeQueue.length > 0 || commentQueue.length > 0) { |
| ✓ Was returned | while (codeQueue.length > 0 || commentQueue.length > 0) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (codeQueue.length > 0 && (!commentQueue.length || commentQueue[0].range[0] > codeQueue[0].range[0])) {··· result.push(codeQueue.shift()); } else { |
| ✓ Negative was executed (else) | } else {··· var commentToken = commentQueue.shift(); commentToken.isComment = true; result.push(commentToken); } |
| Branch LogicalExpression | |
| ✓ Was returned | if (codeQueue.length > 0 && (!commentQueue.length || commentQueue[0].range[0] > codeQueue[0].range[0])) { |
| ✓ Was returned | if (codeQueue.length > 0 && (!commentQueue.length || commentQueue[0].range[0] > codeQueue[0].range[0])) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (codeQueue.length > 0 && (!commentQueue.length || commentQueue[0].range[0] > codeQueue[0].range[0])) { |
| ✓ Was returned | if (codeQueue.length > 0 && (!commentQueue.length || commentQueue[0].range[0] > codeQueue[0].range[0])) { |
| Function (anonymous_154) | |
|---|---|
| ✓ Was called | _addEOFToken: function(hasErrors) {··· var loc = hasErrors ? {line: 0, column: 0} : { line: this._lines.length, column: this._lines[this._lines.length - 1].length }; this._tokens.push({ type: 'EOF', value: '', range: hasErrors ? [0, 0] : [this._source.length, this._source.length + 1], loc: {start: loc, end: loc} }); }, |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | {line: 0, column: 0} : |
| ✓ Negative was returned (: ...) | {··· line: this._lines.length, column: this._lines[this._lines.length - 1].length }; |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | range: hasErrors ? [0, 0] : [this._source.length, this._source.length + 1], |
| ✓ Negative was returned (: ...) | range: hasErrors ? [0, 0] : [this._source.length, this._source.length + 1], |
| Function (anonymous_155) | |
|---|---|
| ✓ Was called | _addWhitespaceTokens: function(tokens, source) {··· var prevPos = 0; var result = []; // For-loop for maximal speed. for (var i = 0; i < tokens.length; i++) { var token = tokens[i]; var rangeStart = token.range[0]; if (rangeStart !== prevPos) { var whitespace = source.substring(prevPos, rangeStart); result.push({ type: 'Whitespace', value: whitespace, isWhitespace: true }); } result.push(token); prevPos = token.range[1]; } return result; }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (rangeStart !== prevPos) {··· var whitespace = source.substring(prevPos, rangeStart); result.push({ type: 'Whitespace', value: whitespace, isWhitespace: true }); } |
| ✓ Negative was executed (else) | }··· result.push(token); |
| Function (anonymous_156) | |
|---|---|
| ✓ Was called | _buildNodeIndex: function() {··· var nodesByType = {}; var nodesByStartRange = {}; this.iterate(function(node, parentNode, parentCollection) { var type = node.type; node.parentNode = parentNode; node.parentCollection = parentCollection; (nodesByType[type] || (nodesByType[type] = [])).push(node); // this part builds a node index that uses node start ranges as the key var startRange = node.range[0]; (nodesByStartRange[startRange] || (nodesByStartRange[startRange] = [])).push(node); }); return { nodesByType: nodesByType, nodesByStartRange: nodesByStartRange }; }, |
| Function (anonymous_157) | |
|---|---|
| ✓ Was called | this.iterate(function(node, parentNode, parentCollection) {··· var type = node.type; node.parentNode = parentNode; node.parentCollection = parentCollection; (nodesByType[type] || (nodesByType[type] = [])).push(node); // this part builds a node index that uses node start ranges as the key var startRange = node.range[0]; (nodesByStartRange[startRange] || (nodesByStartRange[startRange] = [])).push(node); }); |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | (nodesByType[type] || (nodesByType[type] = [])).push(node); |
| ✓ Was returned | (nodesByType[type] || (nodesByType[type] = [])).push(node); |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | (nodesByStartRange[startRange] || (nodesByStartRange[startRange] = [])).push(node); |
| ✓ Was returned | (nodesByStartRange[startRange] || (nodesByStartRange[startRange] = [])).push(node); |
| Function (anonymous_158) | |
|---|---|
| ✓ Was called | _fixEsprimaIdentifiers: function() {··· var _this = this; this.iterateNodesByType(['Property', 'MethodDefinition', 'MemberExpression'], function(node) { switch (node.type) { case 'Property': convertKeywordToIdentifierIfRequired(node.key); break; case 'MethodDefinition': convertKeywordToIdentifierIfRequired(node.key); break; case 'MemberExpression': convertKeywordToIdentifierIfRequired(node.property); break; } }); function convertKeywordToIdentifierIfRequired(node) { var token = _this.getTokenByRangeStart(node.range[0]); if (token.type === 'Keyword') { token.type = 'Identifier'; } } } |
| Function (anonymous_159) | |
|---|---|
| ✓ Was called | this.iterateNodesByType(['Property', 'MethodDefinition', 'MemberExpression'], function(node) {··· switch (node.type) { case 'Property': convertKeywordToIdentifierIfRequired(node.key); break; case 'MethodDefinition': convertKeywordToIdentifierIfRequired(node.key); break; case 'MemberExpression': convertKeywordToIdentifierIfRequired(node.property); break; } }); |
| Branch SwitchStatement | |
|---|---|
| ✓ Was evaluated | case 'Property':··· convertKeywordToIdentifierIfRequired(node.key); break; |
| ✓ Was evaluated | case 'MethodDefinition':··· convertKeywordToIdentifierIfRequired(node.key); break; |
| ✓ Was evaluated | case 'MemberExpression':··· convertKeywordToIdentifierIfRequired(node.property); break; |
| Function convertKeywordToIdentifierIfRequired | |
|---|---|
| ✓ Was called | function convertKeywordToIdentifierIfRequired(node) {··· var token = _this.getTokenByRangeStart(node.range[0]); if (token.type === 'Keyword') { token.type = 'Identifier'; } } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (token.type === 'Keyword') {··· token.type = 'Identifier'; } |
| ✓ Negative was executed (else) | }··· } |
| Function parseJavaScriptSource | |
|---|---|
| ✓ Was called | function parseJavaScriptSource(source, esprima, esprimaOptions) {··· var finalEsprimaOptions = { tolerant: true }; if (esprimaOptions) { for (var key in esprimaOptions) { finalEsprimaOptions[key] = esprimaOptions[key]; } } // Set required options finalEsprimaOptions.loc = true; finalEsprimaOptions.range = true; finalEsprimaOptions.comment = true; finalEsprimaOptions.tokens = true; finalEsprimaOptions.sourceType = 'module'; var hashbang = source.indexOf('#!') === 0; var tree; // Convert bin annotation to a comment if (hashbang) { source = '//' + source.substr(2); } var instrumentationData = {}; var hasInstrumentationData = false; // Process special case code like iOS instrumentation imports: `#import 'abc.js';` source = source.replace(/^#!?[^\n]+\n/gm, function(str, pos) { hasInstrumentationData = true; instrumentationData[pos] = str.substring(0, str.length - 1); return '//' + str.slice(2); }); var gritData = {}; var hasGritData = false; // Process grit tags like `<if ...>` and `<include ...>` source = source.replace(/^\s*<\/?\s*(if|include)(?!\w)[^]*?>/gim, function(str, p1, pos) { hasGritData = true; gritData[pos] = str.substring(0, str.length - 1); // Cut 4 characters to save correct line/column info for surrounding code return '/*' + str.slice(4) + '*/'; }); tree = esprima.parse(source, finalEsprimaOptions); // Change the bin annotation comment if (hashbang) { tree.comments[0].type = 'Hashbang'; tree.comments[0].value = '#!' + tree.comments[0].value; } if (hasInstrumentationData) { tree.comments.forEach(function(token) { var rangeStart = token.range[0]; if (instrumentationData.hasOwnProperty(rangeStart)) { token.type = 'InstrumentationDirective'; token.value = instrumentationData[rangeStart]; } }); } if (hasGritData) { tree.comments.forEach(function(token) { var rangeStart = token.range[0]; if (gritData.hasOwnProperty(rangeStart)) { token.type = 'GritTag'; token.value = gritData[rangeStart]; } }); } return tree; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (esprimaOptions) {··· for (var key in esprimaOptions) { finalEsprimaOptions[key] = esprimaOptions[key]; } } |
| ✓ Negative was executed (else) | }··· // Set required options |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (hashbang) {··· source = '//' + source.substr(2); } |
| ✓ Negative was executed (else) | }··· var instrumentationData = {}; |
| Function (anonymous_162) | |
|---|---|
| ✓ Was called | source = source.replace(/^#!?[^\n]+\n/gm, function(str, pos) {··· hasInstrumentationData = true; instrumentationData[pos] = str.substring(0, str.length - 1); return '//' + str.slice(2); }); |
| Function (anonymous_163) | |
|---|---|
| ✓ Was called | source = source.replace(/^\s*<\/?\s*(if|include)(?!\w)[^]*?>/gim, function(str, p1, pos) {··· hasGritData = true; gritData[pos] = str.substring(0, str.length - 1); // Cut 4 characters to save correct line/column info for surrounding code return '/*' + str.slice(4) + '*/'; }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (hashbang) {··· tree.comments[0].type = 'Hashbang'; tree.comments[0].value = '#!' + tree.comments[0].value; } |
| ✓ Negative was executed (else) | }··· if (hasInstrumentationData) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (hasInstrumentationData) {··· tree.comments.forEach(function(token) { var rangeStart = token.range[0]; if (instrumentationData.hasOwnProperty(rangeStart)) { token.type = 'InstrumentationDirective'; token.value = instrumentationData[rangeStart]; } }); } |
| ✓ Negative was executed (else) | }··· if (hasGritData) { |
| Function (anonymous_164) | |
|---|---|
| ✓ Was called | tree.comments.forEach(function(token) {··· var rangeStart = token.range[0]; if (instrumentationData.hasOwnProperty(rangeStart)) { token.type = 'InstrumentationDirective'; token.value = instrumentationData[rangeStart]; } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (instrumentationData.hasOwnProperty(rangeStart)) {··· token.type = 'InstrumentationDirective'; token.value = instrumentationData[rangeStart]; } |
| ✓ Negative was executed (else) | }··· }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (hasGritData) {··· tree.comments.forEach(function(token) { var rangeStart = token.range[0]; if (gritData.hasOwnProperty(rangeStart)) { token.type = 'GritTag'; token.value = gritData[rangeStart]; } }); } |
| ✓ Negative was executed (else) | }··· return tree; |
| Function (anonymous_165) | |
|---|---|
| ✓ Was called | tree.comments.forEach(function(token) {··· var rangeStart = token.range[0]; if (gritData.hasOwnProperty(rangeStart)) { token.type = 'GritTag'; token.value = gritData[rangeStart]; } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (gritData.hasOwnProperty(rangeStart)) {··· token.type = 'GritTag'; token.value = gritData[rangeStart]; } |
| ✗ Negative was not executed (else) | }··· }); |
| Function iterate | |
|---|---|
| ✓ Was called | module.exports.iterate = function iterate(node, cb) {··· if ('type' in node) { estraverse.traverse(node, { enter: function(node, parent) { var parentCollection = []; // parentCollection support var path = this.path(); if (path) { var collectionKey; while (path.length > 0) { var pathElement = path.pop(); if (typeof pathElement === 'string') { collectionKey = pathElement; break; } } parentCollection = parent[collectionKey]; if (!Array.isArray(parentCollection)) { parentCollection = [parentCollection]; } } if (cb(node, parent, parentCollection) === false) { return estraverse.VisitorOption.Skip; } }, keys: keys }); } }; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('type' in node) {··· estraverse.traverse(node, { enter: function(node, parent) { var parentCollection = []; // parentCollection support var path = this.path(); if (path) { var collectionKey; while (path.length > 0) { var pathElement = path.pop(); if (typeof pathElement === 'string') { collectionKey = pathElement; break; } } parentCollection = parent[collectionKey]; if (!Array.isArray(parentCollection)) { parentCollection = [parentCollection]; } } if (cb(node, parent, parentCollection) === false) { return estraverse.VisitorOption.Skip; } }, keys: keys }); } |
| ✓ Negative was executed (else) | }··· }; |
| Function (anonymous_167) | |
|---|---|
| ✓ Was called | enter: function(node, parent) {··· var parentCollection = []; // parentCollection support var path = this.path(); if (path) { var collectionKey; while (path.length > 0) { var pathElement = path.pop(); if (typeof pathElement === 'string') { collectionKey = pathElement; break; } } parentCollection = parent[collectionKey]; if (!Array.isArray(parentCollection)) { parentCollection = [parentCollection]; } } if (cb(node, parent, parentCollection) === false) { return estraverse.VisitorOption.Skip; } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (path) {··· var collectionKey; while (path.length > 0) { var pathElement = path.pop(); if (typeof pathElement === 'string') { collectionKey = pathElement; break; } } parentCollection = parent[collectionKey]; if (!Array.isArray(parentCollection)) { parentCollection = [parentCollection]; } } |
| ✓ Negative was executed (else) | }··· if (cb(node, parent, parentCollection) === false) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof pathElement === 'string') {··· collectionKey = pathElement; break; } |
| ✓ Negative was executed (else) | }··· } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!Array.isArray(parentCollection)) {··· parentCollection = [parentCollection]; } |
| ✓ Negative was executed (else) | }··· } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (cb(node, parent, parentCollection) === false) {··· return estraverse.VisitorOption.Skip; } |
| ✓ Negative was executed (else) | }··· }, |
| Function Configuration | |
|---|---|
| ✓ Was called | function Configuration() {··· /** * List of the registered (not used) presets. * * @protected * @type {Object} */ this._presets = {}; /** * Name of the preset (if used). * * @protected * @type {String|null} */ this._presetName = null; /** * List of loaded presets. * * @protected * @type {String|null} */ this._loadedPresets = []; /** * List of rules instances. * * @protected * @type {Object} */ this._rules = {}; /** * List of configurated rule instances. * * @protected * @type {Object} */ this._ruleSettings = {}; /** * List of configured rules. * * @protected * @type {Array} */ this._configuredRules = []; /** * List of unsupported rules. * * @protected * @type {Array} */ this._unsupportedRuleNames = []; /** * File extensions that would be checked. * * @protected * @type {Array} */ this._fileExtensions = []; /** * Default file extensions that would be checked. * * @protected * @type {Array} */ this._defaultFileExtensions = ['.js']; /** * Exclusion masks. * * @protected * @type {Array} */ this._excludedFileMasks = []; /** * Default exclusion masks, will be rewritten if user has their own masks. * * @protected * @type {Array} */ this._defaultExcludedFileMasks = ['.git/**', 'node_modules/**']; /** * List of existing files that falls under exclusion masks. * * @protected * @type {Array} */ this._excludedFileMatchers = []; /** * Extraction masks. * * @protected * @type {Array} */ this._extractFileMasks = []; /** * Default extractions masks. * * @protected * @type {Array} */ this._defaultExtractFileMasks = ['**/*.+(htm|html|xhtml)']; /** * List of file matchers from which to extract JavaScript. * * @protected * @type {Array} */ this._extractFileMatchers = []; /** * Maxixum amount of error that would be reportered. * * @protected * @type {Number} */ this._maxErrors = defaults.maxErrors; /** * JSCS CWD. * * @protected * @type {String} */ this._basePath = defaults.cwd; /** * List of overrided options (usually from CLI). * * @protected * @type {Object} */ this._overrides = {}; /** * Is "esnext" mode enabled? * * @protected * @type {Boolean} */ this._esnextEnabled = false; /** * Is "ES3" mode enabled?. * * @protected * @type {Boolean} */ this._es3Enabled = false; /** * Custom version of esprima if specified. * * @protected * @type {Object|null} */ this._esprima = null; /** * Options that would be passed to esprima. * * @protected * @type {Object} */ this._esprimaOptions = {}; /** * A filter function that determines whether or not to report an error. * * @protected * @type {Function|null} */ this._errorFilter = null; /** * Should we show rule names in error output? * * @protected * @type {Boolean} */ this._verbose = false; } |
| Function (anonymous_169) | |
|---|---|
| ✓ Was called | Configuration.prototype.load = function(config) {··· // Apply all the options this._processConfig(config); // Load and apply all the rules this._useRules(); }; |
| Function (anonymous_170) | |
|---|---|
| ✓ Was called | Configuration.prototype.getProcessedConfig = function() {··· var result = {}; Object.keys(this._ruleSettings).forEach(function(key) { result[key] = this._ruleSettings[key]; }, this); result.excludeFiles = this._excludedFileMasks; result.fileExtensions = this._fileExtensions; result.extract = this._extractFileMasks; result.maxErrors = this._maxErrors; result.preset = this._presetName; result.esnext = this._esnextEnabled; result.es3 = this._es3Enabled; result.esprima = this._esprima; result.esprimaOptions = this._esprimaOptions; result.errorFilter = this._errorFilter; return result; }; |
| Function (anonymous_171) | |
|---|---|
| ✓ Was called | Object.keys(this._ruleSettings).forEach(function(key) {··· result[key] = this._ruleSettings[key]; }, this); |
| Function (anonymous_172) | |
|---|---|
| ✓ Was called | Configuration.prototype.getConfiguredRules = function() {··· return this._configuredRules; }; |
| Function (anonymous_173) | |
|---|---|
| ✓ Was called | Configuration.prototype.getConfiguredRule = function(name) {··· return this._configuredRules.filter(function(rule) { return rule.getOptionName() === name; })[0] || null; }; |
| Function (anonymous_174) | |
|---|---|
| ✓ Was called | return this._configuredRules.filter(function(rule) {··· return rule.getOptionName() === name; })[0] || null; |
| Branch LogicalExpression | |
| ✓ Was returned | })[0] || null; |
| ✓ Was returned | return this._configuredRules.filter(function(rule) {··· return rule.getOptionName() === name; })[0] || null; |
| Function (anonymous_175) | |
|---|---|
| ✓ Was called | Configuration.prototype.getUnsupportedRuleNames = function() {··· return this._unsupportedRuleNames; }; |
| Function (anonymous_176) | |
|---|---|
| ✓ Was called | Configuration.prototype.getExcludedFileMasks = function() {··· return this._excludedFileMasks; }; |
| Function (anonymous_177) | |
|---|---|
| ✓ Was called | Configuration.prototype.isFileExcluded = function(filePath) {··· filePath = path.resolve(filePath); return this._excludedFileMatchers.some(function(matcher) { return matcher.match(filePath); }); }; |
| Function (anonymous_178) | |
|---|---|
| ✓ Was called | return this._excludedFileMatchers.some(function(matcher) {··· return matcher.match(filePath); }); |
| Function (anonymous_179) | |
|---|---|
| ✓ Was called | Configuration.prototype.getFileExtensions = function() {··· return this._fileExtensions; }; |
| Function (anonymous_180) | |
|---|---|
| ✓ Was called | Configuration.prototype.getExtractFileMasks = function() {··· return this._extractFileMasks; }; |
| Function (anonymous_181) | |
|---|---|
| ✓ Was called | Configuration.prototype.shouldExtractFile = function(filePath) {··· filePath = path.resolve(filePath); return this._extractFileMatchers.some(function(matcher) { return matcher.match(filePath); }); }; |
| Function (anonymous_182) | |
|---|---|
| ✓ Was called | return this._extractFileMatchers.some(function(matcher) {··· return matcher.match(filePath); }); |
| Function (anonymous_183) | |
|---|---|
| ✓ Was called | Configuration.prototype.getMaxErrors = function() {··· return this._maxErrors; }; |
| Function (anonymous_184) | |
|---|---|
| ✓ Was called | Configuration.prototype.getFix = function() {··· return !!this._fix; }; |
| Function (anonymous_185) | |
|---|---|
| ✓ Was called | Configuration.prototype.isESNextEnabled = function() {··· return this._esnextEnabled; }; |
| Function (anonymous_186) | |
|---|---|
| ✓ Was called | Configuration.prototype.isES3Enabled = function() {··· return this._es3Enabled; }; |
| Function (anonymous_187) | |
|---|---|
| ✓ Was called | Configuration.prototype.hasCustomEsprima = function() {··· return !!this._esprima; }; |
| Function (anonymous_188) | |
|---|---|
| ✓ Was called | Configuration.prototype.getCustomEsprima = function() {··· return this._esprima; }; |
| Function (anonymous_189) | |
|---|---|
| ✓ Was called | Configuration.prototype.getVerbose = function() {··· return this._verbose || false; }; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | return this._verbose || false; |
| ✓ Was returned | return this._verbose || false; |
| Function (anonymous_190) | |
|---|---|
| ✓ Was called | Configuration.prototype.getEsprimaOptions = function() {··· return this._esprimaOptions; }; |
| Function (anonymous_191) | |
|---|---|
| ✓ Was called | Configuration.prototype.getErrorFilter = function() {··· return this._errorFilter; }; |
| Function (anonymous_192) | |
|---|---|
| ✓ Was called | Configuration.prototype.getBasePath = function() {··· return this._basePath; }; |
| Function (anonymous_193) | |
|---|---|
| ✓ Was called | Configuration.prototype.override = function(overrides) {··· Object.keys(overrides).forEach(function(key) { this._overrides[key] = overrides[key]; }, this); }; |
| Function (anonymous_194) | |
|---|---|
| ✓ Was called | Object.keys(overrides).forEach(function(key) {··· this._overrides[key] = overrides[key]; }, this); |
| Function (anonymous_195) | |
|---|---|
| ✓ Was called | Configuration.prototype._getOptionsFromConfig = function(config) {··· return Object.keys(config).reduce(function(options, key) { if (BUILTIN_OPTIONS[key]) { options[key] = config[key]; } return options; }, {}); }; |
| Function (anonymous_196) | |
|---|---|
| ✓ Was called | return Object.keys(config).reduce(function(options, key) {··· if (BUILTIN_OPTIONS[key]) { options[key] = config[key]; } return options; }, {}); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (BUILTIN_OPTIONS[key]) {··· options[key] = config[key]; } |
| ✓ Negative was executed (else) | }··· return options; |
| Function (anonymous_197) | |
|---|---|
| ✓ Was called | Configuration.prototype._processConfig = function(config) {··· var overrides = this._overrides; var currentConfig = {}; // Copy configuration so original config would be intact copyConfiguration(config, currentConfig); // Override the properties copyConfiguration(overrides, currentConfig); // NOTE: options is a separate object to ensure that future options must be added // to BUILTIN_OPTIONS to work, which also assures they aren't mistaken for a rule var options = this._getOptionsFromConfig(currentConfig); // Base path if (this._basePath === defaults.cwd && options.configPath) { assert( typeof options.configPath === 'string', '`configPath` option requires string value' ); this._basePath = path.dirname(options.configPath); } if (options.hasOwnProperty('plugins')) { assert(Array.isArray(options.plugins), '`plugins` option requires array value'); options.plugins.forEach(function(plugin) { this._loadPlugin(plugin, options.configPath); }, this); } if (options.hasOwnProperty('additionalRules')) { assert(Array.isArray(options.additionalRules), '`additionalRules` option requires array value'); options.additionalRules.forEach(function(rule) { this._loadAdditionalRule(rule, options.configPath); }, this); } if (options.hasOwnProperty('extract')) { this._loadExtract(options.extract); } if (options.hasOwnProperty('fileExtensions')) { this._loadFileExtensions(options.fileExtensions); // Set default extensions if there is no presets that could define their own } else if (!options.hasOwnProperty('preset')) { this._loadFileExtensions(this._defaultFileExtensions); } if (options.hasOwnProperty('excludeFiles')) { this._loadExcludedFiles(options.excludeFiles); // Set default masks if there is no presets that could define their own } else if (!options.hasOwnProperty('preset')) { this._loadExcludedFiles(this._defaultExcludedFileMasks); } if (options.hasOwnProperty('fix')) { this._loadFix(options.fix); } this._loadMaxError(options); if (options.hasOwnProperty('esnext')) { this._loadESNext(options.esnext); } if (options.hasOwnProperty('es3')) { this._loadES3(options.es3); } if (options.hasOwnProperty('esprima')) { this._loadEsprima(options.esprima, options.configPath); } if (options.hasOwnProperty('esprimaOptions')) { this._loadEsprimaOptions(options.esprimaOptions); } if (options.hasOwnProperty('errorFilter')) { this._loadErrorFilter(options.errorFilter, options.configPath); } if (options.hasOwnProperty('verbose')) { this._loadVerbose(options.verbose); } // Apply presets if (options.hasOwnProperty('preset')) { this._loadPreset(options.preset, options.configPath); } this._loadRules(currentConfig); }; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._basePath === defaults.cwd && options.configPath) {··· assert( typeof options.configPath === 'string', '`configPath` option requires string value' ); this._basePath = path.dirname(options.configPath); } |
| ✓ Negative was executed (else) | }··· if (options.hasOwnProperty('plugins')) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (this._basePath === defaults.cwd && options.configPath) { |
| ✓ Was returned | if (this._basePath === defaults.cwd && options.configPath) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options.hasOwnProperty('plugins')) {··· assert(Array.isArray(options.plugins), '`plugins` option requires array value'); options.plugins.forEach(function(plugin) { this._loadPlugin(plugin, options.configPath); }, this); } |
| ✓ Negative was executed (else) | }··· if (options.hasOwnProperty('additionalRules')) { |
| Function (anonymous_198) | |
|---|---|
| ✓ Was called | options.plugins.forEach(function(plugin) {··· this._loadPlugin(plugin, options.configPath); }, this); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options.hasOwnProperty('additionalRules')) {··· assert(Array.isArray(options.additionalRules), '`additionalRules` option requires array value'); options.additionalRules.forEach(function(rule) { this._loadAdditionalRule(rule, options.configPath); }, this); } |
| ✓ Negative was executed (else) | }··· if (options.hasOwnProperty('extract')) { |
| Function (anonymous_199) | |
|---|---|
| ✓ Was called | options.additionalRules.forEach(function(rule) {··· this._loadAdditionalRule(rule, options.configPath); }, this); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options.hasOwnProperty('extract')) {··· this._loadExtract(options.extract); } |
| ✓ Negative was executed (else) | }··· if (options.hasOwnProperty('fileExtensions')) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options.hasOwnProperty('fileExtensions')) {··· this._loadFileExtensions(options.fileExtensions); // Set default extensions if there is no presets that could define their own } else if (!options.hasOwnProperty('preset')) { |
| ✓ Negative was executed (else) | } else if (!options.hasOwnProperty('preset')) {··· this._loadFileExtensions(this._defaultFileExtensions); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (!options.hasOwnProperty('preset')) {··· this._loadFileExtensions(this._defaultFileExtensions); } |
| ✓ Negative was executed (else) | }··· if (options.hasOwnProperty('excludeFiles')) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options.hasOwnProperty('excludeFiles')) {··· this._loadExcludedFiles(options.excludeFiles); // Set default masks if there is no presets that could define their own } else if (!options.hasOwnProperty('preset')) { |
| ✓ Negative was executed (else) | } else if (!options.hasOwnProperty('preset')) {··· this._loadExcludedFiles(this._defaultExcludedFileMasks); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (!options.hasOwnProperty('preset')) {··· this._loadExcludedFiles(this._defaultExcludedFileMasks); } |
| ✓ Negative was executed (else) | }··· if (options.hasOwnProperty('fix')) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options.hasOwnProperty('fix')) {··· this._loadFix(options.fix); } |
| ✓ Negative was executed (else) | }··· this._loadMaxError(options); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options.hasOwnProperty('esnext')) {··· this._loadESNext(options.esnext); } |
| ✓ Negative was executed (else) | }··· if (options.hasOwnProperty('es3')) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options.hasOwnProperty('es3')) {··· this._loadES3(options.es3); } |
| ✓ Negative was executed (else) | }··· if (options.hasOwnProperty('esprima')) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options.hasOwnProperty('esprima')) {··· this._loadEsprima(options.esprima, options.configPath); } |
| ✓ Negative was executed (else) | }··· if (options.hasOwnProperty('esprimaOptions')) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options.hasOwnProperty('esprimaOptions')) {··· this._loadEsprimaOptions(options.esprimaOptions); } |
| ✓ Negative was executed (else) | }··· if (options.hasOwnProperty('errorFilter')) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options.hasOwnProperty('errorFilter')) {··· this._loadErrorFilter(options.errorFilter, options.configPath); } |
| ✓ Negative was executed (else) | }··· if (options.hasOwnProperty('verbose')) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options.hasOwnProperty('verbose')) {··· this._loadVerbose(options.verbose); } |
| ✓ Negative was executed (else) | }··· // Apply presets |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options.hasOwnProperty('preset')) {··· this._loadPreset(options.preset, options.configPath); } |
| ✓ Negative was executed (else) | }··· this._loadRules(currentConfig); |
| Function (anonymous_200) | |
|---|---|
| ✓ Was called | Configuration.prototype._loadPlugin = function(plugin) {··· assert(typeof plugin === 'function', '`plugin` should be a function'); plugin(this); }; |
| Function (anonymous_201) | |
|---|---|
| ✓ Was called | Configuration.prototype._loadRules = function(config) {··· Object.keys(config).forEach(function(key) { // Only rules should be processed if (BUILTIN_OPTIONS[key]) { return; } if (this._rules[key]) { var optionValue = config[key]; // Disable rule it it equals "false" or "null" if (optionValue === null || optionValue === false) { delete this._ruleSettings[key]; } else { this._ruleSettings[key] = config[key]; } } else if (this._unsupportedRuleNames.indexOf(key) === -1) { this._unsupportedRuleNames.push(key); } }, this); }; |
| Function (anonymous_202) | |
|---|---|
| ✓ Was called | Object.keys(config).forEach(function(key) {··· // Only rules should be processed if (BUILTIN_OPTIONS[key]) { return; } if (this._rules[key]) { var optionValue = config[key]; // Disable rule it it equals "false" or "null" if (optionValue === null || optionValue === false) { delete this._ruleSettings[key]; } else { this._ruleSettings[key] = config[key]; } } else if (this._unsupportedRuleNames.indexOf(key) === -1) { this._unsupportedRuleNames.push(key); } }, this); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (BUILTIN_OPTIONS[key]) {··· return; } |
| ✓ Negative was executed (else) | }··· if (this._rules[key]) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._rules[key]) {··· var optionValue = config[key]; // Disable rule it it equals "false" or "null" if (optionValue === null || optionValue === false) { delete this._ruleSettings[key]; } else { this._ruleSettings[key] = config[key]; } } else if (this._unsupportedRuleNames.indexOf(key) === -1) { |
| ✓ Negative was executed (else) | } else if (this._unsupportedRuleNames.indexOf(key) === -1) {··· this._unsupportedRuleNames.push(key); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (optionValue === null || optionValue === false) {··· delete this._ruleSettings[key]; } else { |
| ✓ Negative was executed (else) | } else {··· this._ruleSettings[key] = config[key]; } |
| Branch LogicalExpression | |
| ✓ Was returned | if (optionValue === null || optionValue === false) { |
| ✓ Was returned | if (optionValue === null || optionValue === false) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (this._unsupportedRuleNames.indexOf(key) === -1) {··· this._unsupportedRuleNames.push(key); } |
| ✓ Negative was executed (else) | }··· }, this); |
| Function (anonymous_203) | |
|---|---|
| ✓ Was called | Configuration.prototype._loadErrorFilter = function(errorFilter) {··· assert( typeof errorFilter === 'function' || errorFilter === null, '`errorFilter` option requires a function or null value' ); this._errorFilter = errorFilter; }; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | errorFilter === null, |
| ✓ Was returned | typeof errorFilter === 'function' || |
| Function (anonymous_204) | |
|---|---|
| ✓ Was called | Configuration.prototype._loadVerbose = function(verbose) {··· assert( typeof verbose === 'boolean' || verbose === null, '`verbose` option requires a boolean or null value' ); this._verbose = verbose; }; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | typeof verbose === 'boolean' || verbose === null, |
| ✓ Was returned | typeof verbose === 'boolean' || verbose === null, |
| Function (anonymous_205) | |
|---|---|
| ✓ Was called | Configuration.prototype._loadESNext = function(esnext) {··· assert( typeof esnext === 'boolean' || esnext === null, '`esnext` option requires boolean or null value' ); this._esnextEnabled = Boolean(esnext); }; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | typeof esnext === 'boolean' || esnext === null, |
| ✓ Was returned | typeof esnext === 'boolean' || esnext === null, |
| Function (anonymous_206) | |
|---|---|
| ✓ Was called | Configuration.prototype._loadES3 = function(es3) {··· assert( typeof es3 === 'boolean' || es3 === null, '`es3` option requires boolean or null value' ); this._es3Enabled = Boolean(es3); }; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | typeof es3 === 'boolean' || es3 === null, |
| ✓ Was returned | typeof es3 === 'boolean' || es3 === null, |
| Function (anonymous_207) | |
|---|---|
| ✓ Was called | Configuration.prototype._loadMaxError = function(options) {··· // If "fix" option is enabled, set to Inifinity, otherwise this option // doesn't make sense with "fix" conjunction if (this._fix === true) { this._maxErrors = Infinity; return; } if (!options.hasOwnProperty('maxErrors')) { return; } var maxErrors = options.maxErrors === null ? null : Number(options.maxErrors); assert( maxErrors === -1 || maxErrors > 0 || maxErrors === null, '`maxErrors` option requires -1, null value or positive number' ); this._maxErrors = maxErrors; }; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._fix === true) {··· this._maxErrors = Infinity; return; } |
| ✓ Negative was executed (else) | }··· if (!options.hasOwnProperty('maxErrors')) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!options.hasOwnProperty('maxErrors')) {··· return; } |
| ✓ Negative was executed (else) | }··· var maxErrors = options.maxErrors === null ? null : Number(options.maxErrors); |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | var maxErrors = options.maxErrors === null ? null : Number(options.maxErrors); |
| ✓ Negative was returned (: ...) | var maxErrors = options.maxErrors === null ? null : Number(options.maxErrors); |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | maxErrors === -1 || maxErrors > 0 || maxErrors === null, |
| ✓ Was returned | maxErrors === -1 || maxErrors > 0 || maxErrors === null, |
| Branch LogicalExpression | |
| ✓ Was returned | maxErrors === -1 || maxErrors > 0 || maxErrors === null, |
| ✗ Was not returned | maxErrors === -1 || maxErrors > 0 || maxErrors === null, |
| Function (anonymous_208) | |
|---|---|
| ✓ Was called | Configuration.prototype._loadFix = function(fix) {··· fix = fix === null ? false : fix; assert( typeof fix === 'boolean', '`fix` option requires boolean or null value' ); this._fix = fix; }; |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | fix = fix === null ? false : fix; |
| ✓ Negative was returned (: ...) | fix = fix === null ? false : fix; |
| Function (anonymous_209) | |
|---|---|
| ✓ Was called | Configuration.prototype._loadEsprima = function(esprima) {··· assert( (esprima && typeof esprima.parse === 'function') || esprima === null, '`esprima` option requires a null value or an object with a parse function' ); this._esprima = esprima; }; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | esprima === null, |
| ✓ Was returned | (esprima && typeof esprima.parse === 'function') || |
| Branch LogicalExpression | |
| ✓ Was returned | (esprima && typeof esprima.parse === 'function') || |
| ✗ Was not returned | (esprima && typeof esprima.parse === 'function') || |
| Function (anonymous_210) | |
|---|---|
| ✓ Was called | Configuration.prototype._loadPreset = function(preset) {··· if (this._loadedPresets.indexOf(preset) > -1) { return; } // Do not keep adding preset from CLI (#2087) delete this._overrides.preset; this._loadedPresets.push(preset); // If preset is loaded from another preset - preserve the original name if (!this._presetName) { this._presetName = preset; } assert(typeof preset === 'string', '`preset` option requires string value'); var presetData = this._presets[preset]; assert(Boolean(presetData), 'Preset "' + preset + '" does not exist'); // Process config from the preset this._processConfig(this._presets[preset]); }; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._loadedPresets.indexOf(preset) > -1) {··· return; } |
| ✓ Negative was executed (else) | }··· // Do not keep adding preset from CLI (#2087) |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!this._presetName) {··· this._presetName = preset; } |
| ✓ Negative was executed (else) | }··· assert(typeof preset === 'string', '`preset` option requires string value'); |
| Function (anonymous_211) | |
|---|---|
| ✓ Was called | Configuration.prototype._loadFileExtensions = function(extensions) {··· assert( typeof extensions === 'string' || Array.isArray(extensions), '`fileExtensions` option requires string or array value' ); this._fileExtensions = this._fileExtensions.concat(extensions).map(function(ext) { return ext.toLowerCase(); }); }; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | typeof extensions === 'string' || Array.isArray(extensions), |
| ✓ Was returned | typeof extensions === 'string' || Array.isArray(extensions), |
| Function (anonymous_212) | |
|---|---|
| ✓ Was called | this._fileExtensions = this._fileExtensions.concat(extensions).map(function(ext) {··· return ext.toLowerCase(); }); |
| Function (anonymous_213) | |
|---|---|
| ✓ Was called | Configuration.prototype._loadExcludedFiles = function(masks) {··· assert(Array.isArray(masks), '`excludeFiles` option requires array value'); this._excludedFileMasks = this._excludedFileMasks.concat(masks); this._excludedFileMatchers = this._excludedFileMasks.map(function(fileMask) { return new minimatch.Minimatch(path.resolve(this._basePath, fileMask), { dot: true }); }, this); }; |
| Function (anonymous_214) | |
|---|---|
| ✓ Was called | this._excludedFileMatchers = this._excludedFileMasks.map(function(fileMask) {··· return new minimatch.Minimatch(path.resolve(this._basePath, fileMask), { dot: true }); }, this); |
| Function (anonymous_215) | |
|---|---|
| ✓ Was called | Configuration.prototype._loadExtract = function(masks) {··· if (masks === true) { masks = this._defaultExtractFileMasks; } else if (masks === false) { masks = []; } assert(Array.isArray(masks), '`extract` option should be array of strings'); this._extractFileMasks = masks.slice(); this._extractFileMatchers = this._extractFileMasks.map(function(fileMask) { return new minimatch.Minimatch(path.resolve(this._basePath, fileMask), { dot: true }); }, this); }; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (masks === true) {··· masks = this._defaultExtractFileMasks; } else if (masks === false) { |
| ✓ Negative was executed (else) | } else if (masks === false) {··· masks = []; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (masks === false) {··· masks = []; } |
| ✓ Negative was executed (else) | }··· assert(Array.isArray(masks), '`extract` option should be array of strings'); |
| Function (anonymous_216) | |
|---|---|
| ✓ Was called | this._extractFileMatchers = this._extractFileMasks.map(function(fileMask) {··· return new minimatch.Minimatch(path.resolve(this._basePath, fileMask), { dot: true }); }, this); |
| Function (anonymous_217) | |
|---|---|
| ✓ Was called | Configuration.prototype._loadEsprimaOptions = function(esprimaOptions) {··· assert(typeof esprimaOptions === 'object' && esprimaOptions !== null, '`esprimaOptions` should be an object'); this._esprimaOptions = esprimaOptions; }; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | assert(typeof esprimaOptions === 'object' && esprimaOptions !== null, '`esprimaOptions` should be an object'); |
| ✓ Was returned | assert(typeof esprimaOptions === 'object' && esprimaOptions !== null, '`esprimaOptions` should be an object'); |
| Function (anonymous_218) | |
|---|---|
| ✓ Was called | Configuration.prototype._loadAdditionalRule = function(additionalRule) {··· assert(typeof additionalRule === 'object', '`additionalRule` should be an object'); this.registerRule(additionalRule); }; |
| Function (anonymous_219) | |
|---|---|
| ✓ Was called | Configuration.prototype.usePlugin = function(plugin) {··· this._loadPlugin(plugin); }; |
| Function (anonymous_220) | |
|---|---|
| ✓ Was called | Configuration.prototype._useRules = function() {··· this._configuredRules = []; Object.keys(this._ruleSettings).forEach(function(optionName) { var rule = this._rules[optionName]; rule.configure(this._ruleSettings[optionName]); this._configuredRules.push(rule); }, this); }; |
| Function (anonymous_221) | |
|---|---|
| ✓ Was called | Object.keys(this._ruleSettings).forEach(function(optionName) {··· var rule = this._rules[optionName]; rule.configure(this._ruleSettings[optionName]); this._configuredRules.push(rule); }, this); |
| Function (anonymous_222) | |
|---|---|
| ✓ Was called | Configuration.prototype.registerRule = function(rule) {··· if (typeof rule === 'function') { var RuleClass = rule; rule = new RuleClass(); } var optionName = rule.getOptionName(); assert(!this._rules.hasOwnProperty(optionName), 'Rule "' + optionName + '" is already registered'); this._rules[optionName] = rule; }; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof rule === 'function') {··· var RuleClass = rule; rule = new RuleClass(); } |
| ✓ Negative was executed (else) | }··· var optionName = rule.getOptionName(); |
| Function (anonymous_223) | |
|---|---|
| ✓ Was called | Configuration.prototype.getRegisteredRules = function() {··· var rules = this._rules; return Object.keys(rules).map(function(ruleOptionName) { return rules[ruleOptionName]; }); }; |
| Function (anonymous_224) | |
|---|---|
| ✓ Was called | return Object.keys(rules).map(function(ruleOptionName) {··· return rules[ruleOptionName]; }); |
| Function (anonymous_225) | |
|---|---|
| ✓ Was called | Configuration.prototype.registerPreset = function(presetName, presetConfig) {··· assert(_.isPlainObject(presetConfig), 'Preset should be an object'); for (var key in presetConfig) { assert(typeof presetConfig[key] !== 'function', 'Preset should be an JSON object'); } this._presets[presetName] = presetConfig; }; |
| Function (anonymous_226) | |
|---|---|
| ✓ Was called | Configuration.prototype.getRegisteredPresets = function() {··· return this._presets; }; |
| Function (anonymous_227) | |
|---|---|
| ✓ Was called | Configuration.prototype.hasPreset = function(presetName) {··· return this._presets.hasOwnProperty(presetName); }; |
| Function (anonymous_228) | |
|---|---|
| ✓ Was called | Configuration.prototype.getPresetName = function() {··· return this._presetName; }; |
| Function (anonymous_229) | |
|---|---|
| ✓ Was called | Configuration.prototype.registerDefaultRules = function() {··· /* Important! These rules are linked explicitly to keep browser-version supported. */ this.registerRule(require('../rules/disallow-unused-params')); // Register jsdoc plugin this.registerRule(require('../rules/jsdoc')); /* ES6 only */ this.registerRule(require('../rules/require-parentheses-around-arrow-param')); this.registerRule(require('../rules/disallow-parentheses-around-arrow-param')); this.registerRule(require('../rules/require-numeric-literals')); this.registerRule(require('../rules/require-arrow-functions')); this.registerRule(require('../rules/disallow-arrow-functions')); this.registerRule(require('../rules/require-spread')); this.registerRule(require('../rules/require-template-strings')); this.registerRule(require('../rules/require-shorthand-arrow-functions')); this.registerRule(require('../rules/disallow-shorthand-arrow-functions')); this.registerRule(require('../rules/disallow-identical-destructuring-names')); this.registerRule(require('../rules/require-spaces-in-generator')); this.registerRule(require('../rules/disallow-spaces-in-generator')); this.registerRule(require('../rules/disallow-spaces-inside-template-string-placeholders')); this.registerRule(require('../rules/require-object-destructuring')); this.registerRule(require('../rules/require-enhanced-object-literals')); this.registerRule(require('../rules/require-array-destructuring')); this.registerRule(require('../rules/disallow-var')); this.registerRule(require('../rules/require-imports-alphabetized')); this.registerRule(require('../rules/require-space-before-destructured-values')); this.registerRule(require('../rules/disallow-array-destructuring-return')); /* ES6 only (end) */ this.registerRule(require('../rules/require-curly-braces')); this.registerRule(require('../rules/disallow-curly-braces')); this.registerRule(require('../rules/require-multiple-var-decl')); this.registerRule(require('../rules/disallow-multiple-var-decl')); this.registerRule(require('../rules/require-var-decl-first')); this.registerRule(require('../rules/disallow-empty-blocks')); this.registerRule(require('../rules/require-space-after-keywords')); this.registerRule(require('../rules/require-space-before-keywords')); this.registerRule(require('../rules/disallow-space-after-keywords')); this.registerRule(require('../rules/disallow-space-before-keywords')); this.registerRule(require('../rules/require-parentheses-around-iife')); this.registerRule(require('../rules/require-operator-before-line-break')); this.registerRule(require('../rules/disallow-operator-before-line-break')); this.registerRule(require('../rules/disallow-implicit-type-conversion')); this.registerRule(require('../rules/require-camelcase-or-uppercase-identifiers')); this.registerRule(require('../rules/disallow-keywords')); this.registerRule(require('../rules/disallow-multiple-line-breaks')); this.registerRule(require('../rules/disallow-multiple-line-strings')); this.registerRule(require('../rules/disallow-multiple-spaces')); this.registerRule(require('../rules/validate-line-breaks')); this.registerRule(require('../rules/validate-quote-marks')); this.registerRule(require('../rules/validate-indentation')); this.registerRule(require('../rules/disallow-trailing-whitespace')); this.registerRule(require('../rules/disallow-mixed-spaces-and-tabs')); this.registerRule(require('../rules/require-object-keys-on-new-line')); this.registerRule(require('../rules/disallow-object-keys-on-new-line')); this.registerRule(require('../rules/require-keywords-on-new-line')); this.registerRule(require('../rules/disallow-keywords-on-new-line')); this.registerRule(require('../rules/require-line-feed-at-file-end')); this.registerRule(require('../rules/maximum-line-length')); this.registerRule(require('../rules/require-yoda-conditions')); this.registerRule(require('../rules/disallow-yoda-conditions')); this.registerRule(require('../rules/require-spaces-inside-brackets')); this.registerRule(require('../rules/require-spaces-inside-object-brackets')); this.registerRule(require('../rules/require-spaces-inside-array-brackets')); this.registerRule(require('../rules/require-spaces-inside-parentheses')); this.registerRule(require('../rules/require-spaces-inside-parenthesized-expression')); this.registerRule(require('../rules/disallow-spaces-inside-brackets')); this.registerRule(require('../rules/disallow-spaces-inside-object-brackets')); this.registerRule(require('../rules/disallow-spaces-inside-array-brackets')); this.registerRule(require('../rules/disallow-spaces-inside-parentheses')); this.registerRule(require('../rules/disallow-spaces-inside-parenthesized-expression')); this.registerRule(require('../rules/require-blocks-on-newline')); this.registerRule(require('../rules/require-space-after-object-keys')); this.registerRule(require('../rules/require-space-before-object-values')); this.registerRule(require('../rules/disallow-space-after-object-keys')); this.registerRule(require('../rules/disallow-space-before-object-values')); this.registerRule(require('../rules/disallow-quoted-keys-in-objects')); this.registerRule(require('../rules/require-quoted-keys-in-objects')); this.registerRule(require('../rules/disallow-dangling-underscores')); this.registerRule(require('../rules/require-aligned-object-values')); this.registerRule(require('../rules/validate-aligned-function-parameters')); this.registerRule(require('../rules/disallow-padding-newlines-after-blocks')); this.registerRule(require('../rules/require-padding-newlines-after-blocks')); this.registerRule(require('../rules/disallow-padding-newlines-in-blocks')); this.registerRule(require('../rules/require-padding-newlines-in-blocks')); this.registerRule(require('../rules/require-padding-newlines-in-objects')); this.registerRule(require('../rules/disallow-padding-newlines-in-objects')); this.registerRule(require('../rules/require-newline-before-block-statements')); this.registerRule(require('../rules/disallow-newline-before-block-statements')); this.registerRule(require('../rules/require-padding-newlines-before-keywords')); this.registerRule(require('../rules/disallow-padding-newlines-before-keywords')); this.registerRule(require('../rules/disallow-padding-newlines-before-line-comments')); this.registerRule(require('../rules/require-padding-newlines-before-line-comments')); this.registerRule(require('../rules/validate-comment-position.js')); this.registerRule(require('../rules/disallow-trailing-comma')); this.registerRule(require('../rules/require-trailing-comma')); this.registerRule(require('../rules/require-dollar-before-jquery-assignment')); this.registerRule(require('../rules/disallow-comma-before-line-break')); this.registerRule(require('../rules/require-comma-before-line-break')); this.registerRule(require('../rules/disallow-space-before-block-statements.js')); this.registerRule(require('../rules/require-space-before-block-statements.js')); this.registerRule(require('../rules/disallow-space-before-postfix-unary-operators.js')); this.registerRule(require('../rules/require-space-before-postfix-unary-operators.js')); this.registerRule(require('../rules/disallow-space-after-prefix-unary-operators.js')); this.registerRule(require('../rules/require-space-after-prefix-unary-operators.js')); this.registerRule(require('../rules/disallow-space-before-binary-operators')); this.registerRule(require('../rules/require-space-before-binary-operators')); this.registerRule(require('../rules/disallow-space-after-binary-operators')); this.registerRule(require('../rules/require-space-after-binary-operators')); this.registerRule(require('../rules/require-spaces-in-conditional-expression')); this.registerRule(require('../rules/disallow-spaces-in-conditional-expression')); this.registerRule(require('../rules/require-multi-line-ternary')); this.registerRule(require('../rules/disallow-multi-line-ternary')); this.registerRule(require('../rules/disallow-nested-ternaries')); this.registerRule(require('../rules/require-spaces-in-function')); this.registerRule(require('../rules/disallow-spaces-in-function')); this.registerRule(require('../rules/require-spaces-in-function-expression')); this.registerRule(require('../rules/disallow-spaces-in-function-expression')); this.registerRule(require('../rules/require-spaces-in-anonymous-function-expression')); this.registerRule(require('../rules/disallow-spaces-in-anonymous-function-expression')); this.registerRule(require('../rules/require-spaces-in-named-function-expression')); this.registerRule(require('../rules/disallow-spaces-in-named-function-expression')); this.registerRule(require('../rules/require-spaces-in-function-declaration')); this.registerRule(require('../rules/disallow-spaces-in-function-declaration')); this.registerRule(require('../rules/require-spaces-in-call-expression')); this.registerRule(require('../rules/disallow-spaces-in-call-expression')); this.registerRule(require('../rules/validate-parameter-separator')); this.registerRule(require('../rules/require-space-between-arguments')); this.registerRule(require('../rules/disallow-space-between-arguments')); this.registerRule(require('../rules/require-capitalized-constructors')); this.registerRule(require('../rules/require-capitalized-constructors-new')); this.registerRule(require('../rules/safe-context-keyword')); this.registerRule(require('../rules/require-dot-notation')); this.registerRule(require('../rules/require-space-after-line-comment')); this.registerRule(require('../rules/disallow-space-after-line-comment')); this.registerRule(require('../rules/require-anonymous-functions')); this.registerRule(require('../rules/disallow-anonymous-functions')); this.registerRule(require('../rules/require-named-unassigned-functions')); this.registerRule(require('../rules/disallow-named-unassigned-functions')); this.registerRule(require('../rules/require-function-declarations')); this.registerRule(require('../rules/disallow-function-declarations')); this.registerRule(require('../rules/require-capitalized-comments')); this.registerRule(require('../rules/disallow-capitalized-comments')); this.registerRule(require('../rules/require-line-break-after-variable-assignment')); this.registerRule(require('../rules/require-padding-newline-after-variable-declaration')); this.registerRule(require('../rules/disallow-padding-newlines-after-use-strict')); this.registerRule(require('../rules/require-padding-newlines-after-use-strict')); this.registerRule(require('../rules/disallow-padding-newlines-before-export')); this.registerRule(require('../rules/require-padding-newlines-before-export')); this.registerRule(require('../rules/require-semicolons')); this.registerRule(require('../rules/disallow-semicolons')); this.registerRule(require('../rules/require-spaces-in-for-statement')); this.registerRule(require('../rules/disallow-spaces-in-for-statement')); this.registerRule(require('../rules/disallow-node-types')); this.registerRule(require('../rules/disallow-keywords-in-comments')); this.registerRule(require('../rules/disallow-identifier-names')); this.registerRule(require('../rules/maximum-number-of-lines')); this.registerRule(require('../rules/validate-newline-after-array-elements')); this.registerRule(require('../rules/disallow-not-operators-in-conditionals')); this.registerRule(require('../rules/require-matching-function-name')); this.registerRule(require('../rules/disallow-space-before-semicolon')); this.registerRule(require('../rules/disallow-space-before-comma')); this.registerRule(require('../rules/disallow-space-after-comma')); this.registerRule(require('../rules/require-space-before-comma')); this.registerRule(require('../rules/require-space-after-comma')); this.registerRule(require('../rules/validate-order-in-object-keys')); this.registerRule(require('../rules/disallow-tabs')); this.registerRule(require('../rules/require-aligned-multiline-params')); this.registerRule(require('../rules/require-early-return')); this.registerRule(require('../rules/require-newline-before-single-statements-in-if')); }; |
| Function (anonymous_230) | |
|---|---|
| ✓ Was called | Configuration.prototype.registerDefaultPresets = function() {··· // https://github.com/airbnb/javascript this.registerPreset('airbnb', require('../../presets/airbnb.json')); // http://javascript.crockford.com/code.html this.registerPreset('crockford', require('../../presets/crockford.json')); // https://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml this.registerPreset('google', require('../../presets/google.json')); // http://gruntjs.com/contributing#syntax this.registerPreset('grunt', require('../../presets/grunt.json')); // https://github.com/rwaldron/idiomatic.js#idiomatic-style-manifesto this.registerPreset('idiomatic', require('../../presets/idiomatic.json')); // https://contribute.jquery.org/style-guide/js/ this.registerPreset('jquery', require('../../presets/jquery.json')); // https://github.com/mrdoob/three.js/wiki/Mr.doob's-Code-Style%E2%84%A2 this.registerPreset('mdcs', require('../../presets/mdcs.json')); // https://github.com/felixge/node-style-guide#nodejs-style-guide this.registerPreset('node-style-guide', require('../../presets/node-style-guide.json')); // https://www.mediawiki.org/wiki/Manual:Coding_conventions/JavaScript this.registerPreset('wikimedia', require('jscs-preset-wikimedia')); // https://make.wordpress.org/core/handbook/coding-standards/javascript/ this.registerPreset('wordpress', require('../../presets/wordpress.json')); // https://github.com/yandex/codestyle/blob/master/javascript.md this.registerPreset('yandex', require('../../presets/yandex.json')); }; |
| Function copyConfiguration | |
|---|---|
| ✓ Was called | function copyConfiguration(source, dest) {··· Object.keys(source).forEach(function(key) { dest[key] = source[key]; }); if (source.configPath) { dest.configPath = source.configPath; } } |
| Function (anonymous_232) | |
|---|---|
| ✓ Was called | Object.keys(source).forEach(function(key) {··· dest[key] = source[key]; }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (source.configPath) {··· dest.configPath = source.configPath; } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_233) | |
|---|---|
| ✓ Was called | var HtmlFile = function(params) {··· this._filename = params.filename; this._lines = params.source.split(rLineSplit); }; |
| Function (anonymous_234) | |
|---|---|
| ✓ Was called | getFilename: function() {··· return this._filename; }, |
| Function (anonymous_235) | |
|---|---|
| ✓ Was called | getLines: function() {··· return this._lines; } |
| Function getScripts | |
|---|---|
| ✓ Was called | function getScripts(html) {··· function onopen(name, attrs) { // tag should be a <script> if (name !== 'script' || // ignore scripts with src attribute attrs.src || // script tag should has no type attribute or attribute should be equal to text/javascript (attrs.type && attrs.type.toLowerCase() !== 'text/javascript')) { return; } // store script content start pos scriptStartPos = parser.endIndex + 1; } function onclose() { if (!scriptStartPos) { return; } // get script content var scriptEndPos = parser.startIndex; var source = html.substring(scriptStartPos, scriptEndPos); // store script content only if it contains non-whitespace characters if (rHasNonWhitespace.test(source)) { scripts.push({ source: source, start: scriptStartPos, end: scriptEndPos }); } // reset script start position scriptStartPos = 0; } var scriptStartPos = 0; var scripts = []; var parser = new htmlparser.Parser({ onopentag: onopen, onclosetag: onclose }); parser.parseComplete(html); return scripts; } |
| Function onopen | |
|---|---|
| ✓ Was called | function onopen(name, attrs) {··· // tag should be a <script> if (name !== 'script' || // ignore scripts with src attribute attrs.src || // script tag should has no type attribute or attribute should be equal to text/javascript (attrs.type && attrs.type.toLowerCase() !== 'text/javascript')) { return; } // store script content start pos scriptStartPos = parser.endIndex + 1; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | (attrs.type && attrs.type.toLowerCase() !== 'text/javascript')) {··· return; } |
| ✓ Negative was executed (else) | }··· // store script content start pos |
| Branch LogicalExpression | |
| ✓ Was returned | (attrs.type && attrs.type.toLowerCase() !== 'text/javascript')) { |
| ✓ Was returned | if (name !== 'script' ||··· // ignore scripts with src attribute attrs.src || |
| Branch LogicalExpression | |
| ✓ Was returned | attrs.src || |
| ✓ Was returned | if (name !== 'script' || |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | (attrs.type && attrs.type.toLowerCase() !== 'text/javascript')) { |
| ✓ Was returned | (attrs.type && attrs.type.toLowerCase() !== 'text/javascript')) { |
| Function onclose | |
|---|---|
| ✓ Was called | function onclose() {··· if (!scriptStartPos) { return; } // get script content var scriptEndPos = parser.startIndex; var source = html.substring(scriptStartPos, scriptEndPos); // store script content only if it contains non-whitespace characters if (rHasNonWhitespace.test(source)) { scripts.push({ source: source, start: scriptStartPos, end: scriptEndPos }); } // reset script start position scriptStartPos = 0; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!scriptStartPos) {··· return; } |
| ✓ Negative was executed (else) | }··· // get script content |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (rHasNonWhitespace.test(source)) {··· scripts.push({ source: source, start: scriptStartPos, end: scriptEndPos }); } |
| ✓ Negative was executed (else) | }··· // reset script start position |
| Function normalizeSource | |
|---|---|
| ✓ Was called | function normalizeSource(source) {··· var lines = source.split(rLineSplit); var lineCount = lines.length; var tabOnlyOffset = false; var spaceOnlyOffset = false; var offset; // remove first list if it's an empty string // usually <script> starts with new line if (!rHasNonWhitespace.test(lines[0])) { lines.shift(); } // replace last line by empty string if it contains only whitespaces // it helps avoid disallowTrailingWhitespace errors on last line if (!rHasNonWhitespace.test(lines[lines.length - 1])) { lines[lines.length - 1] = ''; } // calculate min line offset offset = Math.min.apply(null, lines.map(function(line) { // skip empty lines if (!line) { return Infinity; } // fetch whitespaces at the line beginning var offsetStr = line.match(/^\s*/)[0]; var tabCount = offsetStr.match(/\t*/)[0].length; if (offsetStr.length === line.length) { return 0; } // mixed spaces and tabs in one offset -> don't remove offsets if (tabCount && tabCount !== offsetStr.length) { return 0; } if (tabCount) { if (spaceOnlyOffset) { // no spaces, but previous offset has ony spaces -> mixed spaces and tabs return 0; } else { // remember offset contains only tabs tabOnlyOffset = true; } } else { if (tabOnlyOffset) { // no tabs, but previous offset has only tabs -> mixed spaces and tabs return 0; } else { // remember offset contains only spaces spaceOnlyOffset = true; } } return offsetStr.length; })); // remove common offsets if possible if (offset) { lines = lines.map(function(line) { return line.substr(offset); }); } return { source: lines.join('\n'), offset: offset, lineCount: lineCount }; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!rHasNonWhitespace.test(lines[0])) {··· lines.shift(); } |
| ✓ Negative was executed (else) | }··· // replace last line by empty string if it contains only whitespaces |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!rHasNonWhitespace.test(lines[lines.length - 1])) {··· lines[lines.length - 1] = ''; } |
| ✓ Negative was executed (else) | }··· // calculate min line offset |
| Function (anonymous_240) | |
|---|---|
| ✓ Was called | offset = Math.min.apply(null, lines.map(function(line) {··· // skip empty lines if (!line) { return Infinity; } // fetch whitespaces at the line beginning var offsetStr = line.match(/^\s*/)[0]; var tabCount = offsetStr.match(/\t*/)[0].length; if (offsetStr.length === line.length) { return 0; } // mixed spaces and tabs in one offset -> don't remove offsets if (tabCount && tabCount !== offsetStr.length) { return 0; } if (tabCount) { if (spaceOnlyOffset) { // no spaces, but previous offset has ony spaces -> mixed spaces and tabs return 0; } else { // remember offset contains only tabs tabOnlyOffset = true; } } else { if (tabOnlyOffset) { // no tabs, but previous offset has only tabs -> mixed spaces and tabs return 0; } else { // remember offset contains only spaces spaceOnlyOffset = true; } } return offsetStr.length; })); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!line) {··· return Infinity; } |
| ✓ Negative was executed (else) | }··· // fetch whitespaces at the line beginning |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (offsetStr.length === line.length) {··· return 0; } |
| ✓ Negative was executed (else) | }··· // mixed spaces and tabs in one offset -> don't remove offsets |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (tabCount && tabCount !== offsetStr.length) {··· return 0; } |
| ✓ Negative was executed (else) | }··· if (tabCount) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (tabCount && tabCount !== offsetStr.length) { |
| ✓ Was returned | if (tabCount && tabCount !== offsetStr.length) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (tabCount) {··· if (spaceOnlyOffset) { // no spaces, but previous offset has ony spaces -> mixed spaces and tabs return 0; } else { // remember offset contains only tabs tabOnlyOffset = true; } } else { |
| ✓ Negative was executed (else) | } else {··· if (tabOnlyOffset) { // no tabs, but previous offset has only tabs -> mixed spaces and tabs return 0; } else { // remember offset contains only spaces spaceOnlyOffset = true; } } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (spaceOnlyOffset) {··· // no spaces, but previous offset has ony spaces -> mixed spaces and tabs return 0; } else { |
| ✓ Negative was executed (else) | } else {··· // remember offset contains only tabs tabOnlyOffset = true; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (tabOnlyOffset) {··· // no tabs, but previous offset has only tabs -> mixed spaces and tabs return 0; } else { |
| ✓ Negative was executed (else) | } else {··· // remember offset contains only spaces spaceOnlyOffset = true; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (offset) {··· lines = lines.map(function(line) { return line.substr(offset); }); } |
| ✓ Negative was executed (else) | }··· return { |
| Function (anonymous_241) | |
|---|---|
| ✓ Was called | lines = lines.map(function(line) {··· return line.substr(offset); }); |
| Function extractJs | |
|---|---|
| ✓ Was called | function extractJs(filename, data) {··· var errors = new Errors(new HtmlFile({ filename: filename, source: data })); var scripts = getScripts(data); var sources = []; var line = 1; var lastHtmlPos = 0; scripts.forEach(function(scriptInfo) { // fetch script source and normalize it var normalized = normalizeSource(scriptInfo.source); // add line offset before script line += data.substring(lastHtmlPos, scriptInfo.start).split(rLineSplit).length - 1; sources.push({ source: normalized.source, offset: normalized.offset, line: line }); // save offsets for next fragment line += normalized.lineCount - 1; lastHtmlPos = scriptInfo.end; }); return { sources: sources, errors: errors, addError: function(error) { errors._errorList.push({ filename: filename, rule: error.rule, message: error.message, line: error.line, column: error.column }); } }; } |
| Function (anonymous_243) | |
|---|---|
| ✓ Was called | scripts.forEach(function(scriptInfo) {··· // fetch script source and normalize it var normalized = normalizeSource(scriptInfo.source); // add line offset before script line += data.substring(lastHtmlPos, scriptInfo.start).split(rLineSplit).length - 1; sources.push({ source: normalized.source, offset: normalized.offset, line: line }); // save offsets for next fragment line += normalized.lineCount - 1; lastHtmlPos = scriptInfo.end; }); |
| Function (anonymous_244) | |
|---|---|
| ✓ Was called | addError: function(error) {··· errors._errorList.push({ filename: filename, rule: error.rule, message: error.message, line: error.line, column: error.column }); } |
| Function req | |
|---|---|
| ✓ Was called | function req(entity, dir) {··· return require( resolve.sync(entity, { basedir: dir }) ); } |
| Function NodeConfiguration | |
|---|---|
| ✓ Was called | function NodeConfiguration() {··· Configuration.call(this); this._basePath = process.cwd(); } |
| Function (anonymous_247) | |
|---|---|
| ✓ Was called | NodeConfiguration.prototype.overrideFromCLI = function(program) {··· var overrides = {}; OVERRIDE_OPTIONS.forEach(function(option) { if (option in program) { overrides[option] = program[option]; } }); this.override(overrides); }; |
| Function (anonymous_248) | |
|---|---|
| ✓ Was called | OVERRIDE_OPTIONS.forEach(function(option) {··· if (option in program) { overrides[option] = program[option]; } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (option in program) {··· overrides[option] = program[option]; } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_249) | |
|---|---|
| ✓ Was called | NodeConfiguration.prototype.loadExternal = function(external, type, config) {··· assert( typeof external === 'string' || external === null, '"' + type + '" option requires a string or null value' ); if (external === null) { return null; } var dir = config ? path.dirname(config) : this._basePath; var get = function(prefix, postfix) { prefix = prefix || ''; postfix = postfix || ''; try { return finder( utils.normalizePath(prefix + external + postfix, dir), dir ); } catch (e) {} return null; }.bind(this); var finder; if (type === 'preset') { finder = configFinder.getContent; } else { finder = req; } var content; if (external.indexOf('jscs-') !== 0) { content = get('jscs-'); if (!content && type === 'preset') { content = get('jscs-preset-') || get('jscs-config-'); if (!content && external.indexOf('/') !== -1 && !external.split('.')[1]) { content = get('jscs-', '.json') || get('jscs-', '.js') || get('jscs-preset-', '.json') || get('jscs-config-', '.json') || get('jscs-preset-', '.js') || get('jscs-config-', '.js'); } } } return content || get(); }; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | typeof external === 'string' || external === null, |
| ✓ Was returned | typeof external === 'string' || external === null, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (external === null) {··· return null; } |
| ✓ Negative was executed (else) | }··· var dir = config ? path.dirname(config) : this._basePath; |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | var dir = config ? path.dirname(config) : this._basePath; |
| ✓ Negative was returned (: ...) | var dir = config ? path.dirname(config) : this._basePath; |
| Function (anonymous_250) | |
|---|---|
| ✓ Was called | var get = function(prefix, postfix) {··· prefix = prefix || ''; postfix = postfix || ''; try { return finder( utils.normalizePath(prefix + external + postfix, dir), dir ); } catch (e) {} return null; }.bind(this); |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | prefix = prefix || ''; |
| ✓ Was returned | prefix = prefix || ''; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | postfix = postfix || ''; |
| ✓ Was returned | postfix = postfix || ''; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (type === 'preset') {··· finder = configFinder.getContent; } else { |
| ✓ Negative was executed (else) | } else {··· finder = req; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (external.indexOf('jscs-') !== 0) {··· content = get('jscs-'); if (!content && type === 'preset') { content = get('jscs-preset-') || get('jscs-config-'); if (!content && external.indexOf('/') !== -1 && !external.split('.')[1]) { content = get('jscs-', '.json') || get('jscs-', '.js') || get('jscs-preset-', '.json') || get('jscs-config-', '.json') || get('jscs-preset-', '.js') || get('jscs-config-', '.js'); } } } |
| ✓ Negative was executed (else) | }··· return content || get(); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!content && type === 'preset') {··· content = get('jscs-preset-') || get('jscs-config-'); if (!content && external.indexOf('/') !== -1 && !external.split('.')[1]) { content = get('jscs-', '.json') || get('jscs-', '.js') || get('jscs-preset-', '.json') || get('jscs-config-', '.json') || get('jscs-preset-', '.js') || get('jscs-config-', '.js'); } } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | if (!content && type === 'preset') { |
| ✓ Was returned | if (!content && type === 'preset') { |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | content = get('jscs-preset-') || get('jscs-config-'); |
| ✓ Was returned | content = get('jscs-preset-') || get('jscs-config-'); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!content && external.indexOf('/') !== -1 && !external.split('.')[1]) {··· content = get('jscs-', '.json') || get('jscs-', '.js') || get('jscs-preset-', '.json') || get('jscs-config-', '.json') || get('jscs-preset-', '.js') || get('jscs-config-', '.js'); } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | if (!content && external.indexOf('/') !== -1 && !external.split('.')[1]) { |
| ✓ Was returned | if (!content && external.indexOf('/') !== -1 && !external.split('.')[1]) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (!content && external.indexOf('/') !== -1 && !external.split('.')[1]) { |
| ✓ Was returned | if (!content && external.indexOf('/') !== -1 && !external.split('.')[1]) { |
| Branch LogicalExpression | |
|---|---|
| ✗ Was not returned | get('jscs-config-', '.js'); |
| ✓ Was returned | content = get('jscs-', '.json') ||··· get('jscs-', '.js') || get('jscs-preset-', '.json') || get('jscs-config-', '.json') || get('jscs-preset-', '.js') || |
| Branch LogicalExpression | |
| ✗ Was not returned | get('jscs-preset-', '.js') || |
| ✓ Was returned | content = get('jscs-', '.json') ||··· get('jscs-', '.js') || get('jscs-preset-', '.json') || get('jscs-config-', '.json') || |
| Branch LogicalExpression | |
| ✗ Was not returned | get('jscs-config-', '.json') || |
| ✓ Was returned | content = get('jscs-', '.json') ||··· get('jscs-', '.js') || get('jscs-preset-', '.json') || |
| Branch LogicalExpression | |
| ✓ Was returned | get('jscs-preset-', '.json') || |
| ✓ Was returned | content = get('jscs-', '.json') ||··· get('jscs-', '.js') || |
| Branch LogicalExpression | |
| ✓ Was returned | get('jscs-', '.js') || |
| ✓ Was returned | content = get('jscs-', '.json') || |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | return content || get(); |
| ✓ Was returned | return content || get(); |
| Function (anonymous_251) | |
|---|---|
| ✓ Was called | NodeConfiguration.prototype._loadPlugin = function(plugin, config) {··· if (typeof plugin !== 'function') { plugin = this.loadExternal(plugin, 'plugin', config); } return Configuration.prototype._loadPlugin.call(this, plugin); }; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof plugin !== 'function') {··· plugin = this.loadExternal(plugin, 'plugin', config); } |
| ✓ Negative was executed (else) | }··· return Configuration.prototype._loadPlugin.call(this, plugin); |
| Function (anonymous_252) | |
|---|---|
| ✓ Was called | NodeConfiguration.prototype._loadPreset = function(preset, config) {··· var name = path.basename(preset).split('.')[0]; try { this.registerPreset(name, this.loadExternal(preset, 'preset', config)); } catch (e) { var registeredPresets = this.getRegisteredPresets(); if (preset in registeredPresets) { Configuration.prototype._loadPreset.call(this, preset); return; } } // If preset is an external module, error will be thrown by the caller Configuration.prototype._loadPreset.call(this, name); }; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (preset in registeredPresets) {··· Configuration.prototype._loadPreset.call(this, preset); return; } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_253) | |
|---|---|
| ✓ Was called | NodeConfiguration.prototype._loadErrorFilter = function(filter, config) {··· Configuration.prototype._loadErrorFilter.call( this, this.loadExternal(filter, 'errorFilter', config) ); }; |
| Function (anonymous_254) | |
|---|---|
| ✓ Was called | NodeConfiguration.prototype._loadEsprima = function(esprima, config) {··· Configuration.prototype._loadEsprima.call( this, this.loadExternal(esprima, 'esprima', config) ); }; |
| Function (anonymous_255) | |
|---|---|
| ✓ Was called | NodeConfiguration.prototype._loadAdditionalRule = function(additionalRule, config) {··· config = config || this._basePath; if (typeof additionalRule === 'string') { if (glob.hasMagic(additionalRule)) { // In some cases there might not be a config // like if options are defined through direct initialization (grunt plugin case) config = fs.statSync(config).isDirectory() ? config : path.dirname(config); glob.sync(path.resolve(config, additionalRule)).forEach(function(p) { var Rule = require(p); Configuration.prototype._loadAdditionalRule.call(this, new Rule()); }, this); } else { var Rule = this.loadExternal(additionalRule, 'rule', config); Configuration.prototype._loadAdditionalRule.call(this, new Rule()); } } else { Configuration.prototype._loadAdditionalRule.call(this, additionalRule); } }; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | config = config || this._basePath; |
| ✓ Was returned | config = config || this._basePath; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof additionalRule === 'string') {··· if (glob.hasMagic(additionalRule)) { // In some cases there might not be a config // like if options are defined through direct initialization (grunt plugin case) config = fs.statSync(config).isDirectory() ? config : path.dirname(config); glob.sync(path.resolve(config, additionalRule)).forEach(function(p) { var Rule = require(p); Configuration.prototype._loadAdditionalRule.call(this, new Rule()); }, this); } else { var Rule = this.loadExternal(additionalRule, 'rule', config); Configuration.prototype._loadAdditionalRule.call(this, new Rule()); } } else { |
| ✓ Negative was executed (else) | } else {··· Configuration.prototype._loadAdditionalRule.call(this, additionalRule); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (glob.hasMagic(additionalRule)) {··· // In some cases there might not be a config // like if options are defined through direct initialization (grunt plugin case) config = fs.statSync(config).isDirectory() ? config : path.dirname(config); glob.sync(path.resolve(config, additionalRule)).forEach(function(p) { var Rule = require(p); Configuration.prototype._loadAdditionalRule.call(this, new Rule()); }, this); } else { |
| ✓ Negative was executed (else) | } else {··· var Rule = this.loadExternal(additionalRule, 'rule', config); Configuration.prototype._loadAdditionalRule.call(this, new Rule()); } |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | config = fs.statSync(config).isDirectory() ? config : path.dirname(config); |
| ✓ Negative was returned (: ...) | config = fs.statSync(config).isDirectory() ? config : path.dirname(config); |
| Function (anonymous_256) | |
|---|---|
| ✓ Was called | glob.sync(path.resolve(config, additionalRule)).forEach(function(p) {··· var Rule = require(p); Configuration.prototype._loadAdditionalRule.call(this, new Rule()); }, this); |
| Function (anonymous_257) | |
|---|---|
| ✓ Was called | exports.isValidIdentifierName = function(name, dialect) {··· dialect = dialect || 'es5'; var identifierRegex = dialect === 'es5' ? IDENTIFIER_NAME_ES5_RE : IDENTIFIER_NAME_ES6_RE; return !reservedWords.check(name, dialect, true) && identifierRegex.test(name); }; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | dialect = dialect || 'es5'; |
| ✓ Was returned | dialect = dialect || 'es5'; |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | var identifierRegex = dialect === 'es5' ? IDENTIFIER_NAME_ES5_RE : IDENTIFIER_NAME_ES6_RE; |
| ✓ Negative was returned (: ...) | var identifierRegex = dialect === 'es5' ? IDENTIFIER_NAME_ES5_RE : IDENTIFIER_NAME_ES6_RE; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | return !reservedWords.check(name, dialect, true) && identifierRegex.test(name); |
| ✓ Was returned | return !reservedWords.check(name, dialect, true) && identifierRegex.test(name); |
| Function (anonymous_258) | |
|---|---|
| ✓ Was called | exports.isSnakeCased = function(name) {··· return SNAKE_CASE_RE.test(name); }; |
| Function (anonymous_259) | |
|---|---|
| ✓ Was called | exports.getFunctionNodeFromIIFE = function(node) {··· if (node.type !== 'CallExpression') { return null; } var callee = node.callee; if (callee.type === 'FunctionExpression') { return callee; } if (callee.type === 'MemberExpression' && callee.object.type === 'FunctionExpression' && callee.property.type === 'Identifier' && (callee.property.name === 'call' || callee.property.name === 'apply') ) { return callee.object; } return null; }; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.type !== 'CallExpression') {··· return null; } |
| ✓ Negative was executed (else) | }··· var callee = node.callee; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (callee.type === 'FunctionExpression') {··· return callee; } |
| ✓ Negative was executed (else) | }··· if (callee.type === 'MemberExpression' && |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | ) {··· return callee.object; } |
| ✓ Negative was executed (else) | }··· return null; |
| Branch LogicalExpression | |
| ✓ Was returned | (callee.property.name === 'call' || callee.property.name === 'apply') |
| ✓ Was returned | if (callee.type === 'MemberExpression' &&··· callee.object.type === 'FunctionExpression' && callee.property.type === 'Identifier' && |
| Branch LogicalExpression | |
| ✓ Was returned | callee.property.type === 'Identifier' && |
| ✓ Was returned | if (callee.type === 'MemberExpression' &&··· callee.object.type === 'FunctionExpression' && |
| Branch LogicalExpression | |
| ✓ Was returned | callee.object.type === 'FunctionExpression' && |
| ✓ Was returned | if (callee.type === 'MemberExpression' && |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | (callee.property.name === 'call' || callee.property.name === 'apply') |
| ✓ Was returned | (callee.property.name === 'call' || callee.property.name === 'apply') |
| Function (anonymous_260) | |
|---|---|
| ✓ Was called | exports.trimUnderscores = function(name) {··· var res = name.replace(TRAILING_UNDERSCORES_RE, ''); return res ? res : name; }; |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | return res ? res : name; |
| ✓ Negative was returned (: ...) | return res ? res : name; |
| Function (anonymous_261) | |
|---|---|
| ✓ Was called | exports.isRelativePath = function(path) {··· // Logic from: https://github.com/joyent/node/blob/4f1ae11a62b97052bc83756f8cb8700cc1f61661/lib/module.js#L237 var start = path.substring(0, 2); return start === './' || start === '..'; }; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | return start === './' || start === '..'; |
| ✓ Was returned | return start === './' || start === '..'; |
| Function (anonymous_262) | |
|---|---|
| ✓ Was called | exports.normalizePath = function(filepath, basePath) {··· if (this.isRelativePath(filepath)) { return path.resolve(basePath, filepath); } return filepath; }; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this.isRelativePath(filepath)) {··· return path.resolve(basePath, filepath); } |
| ✓ Negative was executed (else) | }··· return filepath; |
| Function (anonymous_263) | |
|---|---|
| ✓ Was called | exports.promisify = function(fn) {··· return function() { var deferred = Vow.defer(); var args = [].slice.call(arguments); args.push(function(err, result) { if (err) { deferred.reject(err); } else { deferred.resolve(result); } }); fn.apply(null, args); return deferred.promise(); }; }; |
| Function (anonymous_264) | |
|---|---|
| ✓ Was called | return function() {··· var deferred = Vow.defer(); var args = [].slice.call(arguments); args.push(function(err, result) { if (err) { deferred.reject(err); } else { deferred.resolve(result); } }); fn.apply(null, args); return deferred.promise(); }; |
| Function (anonymous_265) | |
|---|---|
| ✓ Was called | args.push(function(err, result) {··· if (err) { deferred.reject(err); } else { deferred.resolve(result); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (err) {··· deferred.reject(err); } else { |
| ✓ Negative was executed (else) | } else {··· deferred.resolve(result); } |
| Function (anonymous_266) | |
|---|---|
| ✓ Was called | exports.isPragma = function(additionalExceptions) {··· var pragmaKeywords = [ 'eslint', 'eslint-env', 'eslint-enable', 'eslint-disable', 'eslint-disable-line', 'global', 'jshint', 'jslint', 'globals', 'falls through', 'exported', 'jscs:', 'jscs:enable', 'jscs:disable', 'jscs:ignore', 'istanbul' ]; if (additionalExceptions && Array.isArray(additionalExceptions)) { pragmaKeywords = pragmaKeywords.concat(additionalExceptions); } return function(comment) { // pragmaKeywords precede a space or the end of the comment var trimmedComment = comment.trim() + ' '; for (var i = 0; i < pragmaKeywords.length; i++) { if (trimmedComment.indexOf(pragmaKeywords[i] + ' ') === 0) { return true; } } return false; }; }; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (additionalExceptions && Array.isArray(additionalExceptions)) {··· pragmaKeywords = pragmaKeywords.concat(additionalExceptions); } |
| ✓ Negative was executed (else) | }··· return function(comment) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (additionalExceptions && Array.isArray(additionalExceptions)) { |
| ✓ Was returned | if (additionalExceptions && Array.isArray(additionalExceptions)) { |
| Function (anonymous_267) | |
|---|---|
| ✓ Was called | return function(comment) {··· // pragmaKeywords precede a space or the end of the comment var trimmedComment = comment.trim() + ' '; for (var i = 0; i < pragmaKeywords.length; i++) { if (trimmedComment.indexOf(pragmaKeywords[i] + ' ') === 0) { return true; } } return false; }; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (trimmedComment.indexOf(pragmaKeywords[i] + ' ') === 0) {··· return true; } |
| ✓ Negative was executed (else) | }··· } |
| Function cli | |
|---|---|
| ✓ Was called | module.exports = function cli(program) {··· var reporter; var config; var checkerPromise; var defer = Vow.defer(); var promise = defer.promise(); var checker = new Checker(); var args = program.args; var returnArgs = { checker: checker, reporter: program.reporter, promise: promise }; function handleMaxErrors() { if (checker.maxErrorsExceeded()) { console.error('Too many errors... Increase `maxErrors` configuration option value to see more.'); } } promise.always(function(status) { exit(status.valueOf()); }); try { config = configFile.load(program.config); } catch (e) { console.error('Config source is corrupted -', e.toString()); defer.reject(5); return returnArgs; } /** * Trying to load config. * Custom config path can be specified using '-c' option. */ if (!config && !program.preset && !program.autoConfigure) { if (program.config) { console.error('Configuration source', program.config, 'was not found.'); } else { console.error('No configuration found. Add a .jscsrc file to your project root or use the -c option.'); } defer.reject(4); return returnArgs; } if (!args.length && process.stdin.isTTY && typeof program.autoConfigure !== 'string') { console.error('No input files specified. Try option --help for usage information.'); defer.reject(3); return returnArgs; } reporter = configFile.getReporter(program.reporter, program.colors); returnArgs.reporter = reporter.path; if (!reporter.writer) { console.error('Reporter "%s" does not exist.', program.reporter); returnArgs.reporter = reporter.path; defer.reject(6); return returnArgs; } if (!config) { config = {}; } // To run autoconfigure over all errors in the path if (program.autoConfigure) { program.maxErrors = Infinity; } checker.getConfiguration().overrideFromCLI(program); checker.getConfiguration().registerDefaultRules(); try { checker.configure(config); } catch (e) { console.error(e.message); defer.reject(1); return returnArgs; } if (program.autoConfigure) { var generator = new ConfigGenerator(); generator .generate(program.autoConfigure) .then(function() { defer.resolve(0); }, function(error) { console.error('Configuration generation failed due to ', error); defer.reject(7); }); return returnArgs; } // Handle usage like 'cat myfile.js | jscs' or 'jscs -'' var usedDash = args[args.length - 1] === '-'; if (!args.length || usedDash) { // So the dash doesn't register as a file if (usedDash) { args.length--; } if (program.fix) { return { promise: checker.fixStdin().then(function(result) { process.stdout.write(result.output); }), checker: checker }; } checkerPromise = checker.checkStdin().then(function(errors) { return [errors]; }); } // Processing specified files and dirs. if (args.length) { checkerPromise = Vow.all(args.map(checker.execute, checker)).then(function(results) { return [].concat.apply([], results); }); } checkerPromise.then(function(errorsCollection) { reporter.writer(errorsCollection); handleMaxErrors(); errorsCollection.forEach(function(errors) { if (!errors.isEmpty()) { defer.reject(2); } }); defer.resolve(0); }).fail(function(e) { console.error(e.stack); defer.reject(1); }); return returnArgs; }; |
| Function handleMaxErrors | |
|---|---|
| ✓ Was called | function handleMaxErrors() {··· if (checker.maxErrorsExceeded()) { console.error('Too many errors... Increase `maxErrors` configuration option value to see more.'); } } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (checker.maxErrorsExceeded()) {··· console.error('Too many errors... Increase `maxErrors` configuration option value to see more.'); } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_270) | |
|---|---|
| ✓ Was called | promise.always(function(status) {··· exit(status.valueOf()); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!config && !program.preset && !program.autoConfigure) {··· if (program.config) { console.error('Configuration source', program.config, 'was not found.'); } else { console.error('No configuration found. Add a .jscsrc file to your project root or use the -c option.'); } defer.reject(4); return returnArgs; } |
| ✓ Negative was executed (else) | }··· if (!args.length && process.stdin.isTTY && typeof program.autoConfigure !== 'string') { |
| Branch LogicalExpression | |
| ✓ Was returned | if (!config && !program.preset && !program.autoConfigure) { |
| ✓ Was returned | if (!config && !program.preset && !program.autoConfigure) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (!config && !program.preset && !program.autoConfigure) { |
| ✓ Was returned | if (!config && !program.preset && !program.autoConfigure) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (program.config) {··· console.error('Configuration source', program.config, 'was not found.'); } else { |
| ✓ Negative was executed (else) | } else {··· console.error('No configuration found. Add a .jscsrc file to your project root or use the -c option.'); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!args.length && process.stdin.isTTY && typeof program.autoConfigure !== 'string') {··· console.error('No input files specified. Try option --help for usage information.'); defer.reject(3); return returnArgs; } |
| ✓ Negative was executed (else) | }··· reporter = configFile.getReporter(program.reporter, program.colors); |
| Branch LogicalExpression | |
| ✓ Was returned | if (!args.length && process.stdin.isTTY && typeof program.autoConfigure !== 'string') { |
| ✓ Was returned | if (!args.length && process.stdin.isTTY && typeof program.autoConfigure !== 'string') { |
| Branch LogicalExpression | |
| ✓ Was returned | if (!args.length && process.stdin.isTTY && typeof program.autoConfigure !== 'string') { |
| ✓ Was returned | if (!args.length && process.stdin.isTTY && typeof program.autoConfigure !== 'string') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!reporter.writer) {··· console.error('Reporter "%s" does not exist.', program.reporter); returnArgs.reporter = reporter.path; defer.reject(6); return returnArgs; } |
| ✓ Negative was executed (else) | }··· if (!config) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!config) {··· config = {}; } |
| ✓ Negative was executed (else) | }··· // To run autoconfigure over all errors in the path |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (program.autoConfigure) {··· program.maxErrors = Infinity; } |
| ✓ Negative was executed (else) | }··· checker.getConfiguration().overrideFromCLI(program); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (program.autoConfigure) {··· var generator = new ConfigGenerator(); generator .generate(program.autoConfigure) .then(function() { defer.resolve(0); }, function(error) { console.error('Configuration generation failed due to ', error); defer.reject(7); }); return returnArgs; } |
| ✓ Negative was executed (else) | }··· // Handle usage like 'cat myfile.js | jscs' or 'jscs -'' |
| Function (anonymous_271) | |
|---|---|
| ✓ Was called | .then(function() {··· defer.resolve(0); }, function(error) { |
| Function (anonymous_272) | |
|---|---|
| ✓ Was called | }, function(error) {··· console.error('Configuration generation failed due to ', error); defer.reject(7); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!args.length || usedDash) {··· // So the dash doesn't register as a file if (usedDash) { args.length--; } if (program.fix) { return { promise: checker.fixStdin().then(function(result) { process.stdout.write(result.output); }), checker: checker }; } checkerPromise = checker.checkStdin().then(function(errors) { return [errors]; }); } |
| ✓ Negative was executed (else) | }··· // Processing specified files and dirs. |
| Branch LogicalExpression | |
| ✓ Was returned | if (!args.length || usedDash) { |
| ✓ Was returned | if (!args.length || usedDash) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (usedDash) { args.length--; } |
| ✓ Negative was executed (else) | if (usedDash) { args.length--; }··· if (program.fix) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (program.fix) {··· return { promise: checker.fixStdin().then(function(result) { process.stdout.write(result.output); }), checker: checker }; } |
| ✓ Negative was executed (else) | }··· checkerPromise = checker.checkStdin().then(function(errors) { |
| Function (anonymous_273) | |
|---|---|
| ✓ Was called | promise: checker.fixStdin().then(function(result) {··· process.stdout.write(result.output); }), |
| Function (anonymous_274) | |
|---|---|
| ✓ Was called | checkerPromise = checker.checkStdin().then(function(errors) {··· return [errors]; }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (args.length) {··· checkerPromise = Vow.all(args.map(checker.execute, checker)).then(function(results) { return [].concat.apply([], results); }); } |
| ✓ Negative was executed (else) | }··· checkerPromise.then(function(errorsCollection) { |
| Function (anonymous_275) | |
|---|---|
| ✓ Was called | checkerPromise = Vow.all(args.map(checker.execute, checker)).then(function(results) {··· return [].concat.apply([], results); }); |
| Function (anonymous_276) | |
|---|---|
| ✓ Was called | checkerPromise.then(function(errorsCollection) {··· reporter.writer(errorsCollection); handleMaxErrors(); errorsCollection.forEach(function(errors) { if (!errors.isEmpty()) { defer.reject(2); } }); defer.resolve(0); }).fail(function(e) { |
| Function (anonymous_277) | |
|---|---|
| ✓ Was called | errorsCollection.forEach(function(errors) {··· if (!errors.isEmpty()) { defer.reject(2); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!errors.isEmpty()) {··· defer.reject(2); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_278) | |
|---|---|
| ✓ Was called | }).fail(function(e) {··· console.error(e.stack); defer.reject(1); }); |
| Function Generator | |
|---|---|
| ✓ Was called | function Generator() {··· this._config = {}; } |
| Function (anonymous_280) | |
|---|---|
| ✓ Was called | Generator.prototype.generate = function(path) {··· var checker = getChecker(); var _path = utils.normalizePath(path, checker.getConfiguration().getBasePath()); var presetNames = Object.keys(checker.getConfiguration().getRegisteredPresets()); var statsForPresets; console.log('Checking', _path, 'against the presets'); return Vow .all(presetNames.map(this._checkAgainstPreset.bind(this, _path))) .then(function(resultsPerPreset) { statsForPresets = this._generateStatsForPresets(resultsPerPreset, presetNames); return statsForPresets; }.bind(this)) .then(this._showErrorCounts.bind(this)) .then(this._getUserPresetChoice.bind(this, prompts[0])) .then(function showViolatedRules(choiceObj) { var presetIndex = choiceObj[prompts[0].name] - 1; var presetName = statsForPresets[presetIndex].name; console.log('You chose the ' + presetName + ' preset'); this._config.preset = presetName; var errorStats = getErrorsByRuleName(statsForPresets[presetIndex].errors); var violatedRuleCount = Object.keys(errorStats).length; if (!violatedRuleCount) { return this._config; } console.log(_path + ' violates ' + violatedRuleCount + ' rule' + (violatedRuleCount > 1 ? 's' : '')); var errorPrompts = generateRuleHandlingPrompts(errorStats); return this._getUserViolationChoices(errorPrompts) .then(this._handleViolatedRules.bind(this, errorPrompts)) .then(function() { return this._config; }.bind(this)); }.bind(this)) .then(function flushConfig() { fs.writeFileSync(process.cwd() + '/.jscsrc', JSON.stringify(this._config, null, '\t')); console.log('Generated a .jscsrc configuration file in ' + process.cwd()); }.bind(this)); }; |
| Function (anonymous_281) | |
|---|---|
| ✓ Was called | .then(function(resultsPerPreset) {··· statsForPresets = this._generateStatsForPresets(resultsPerPreset, presetNames); return statsForPresets; }.bind(this)) |
| Function showViolatedRules | |
|---|---|
| ✓ Was called | .then(function showViolatedRules(choiceObj) {··· var presetIndex = choiceObj[prompts[0].name] - 1; var presetName = statsForPresets[presetIndex].name; console.log('You chose the ' + presetName + ' preset'); this._config.preset = presetName; var errorStats = getErrorsByRuleName(statsForPresets[presetIndex].errors); var violatedRuleCount = Object.keys(errorStats).length; if (!violatedRuleCount) { return this._config; } console.log(_path + ' violates ' + violatedRuleCount + ' rule' + (violatedRuleCount > 1 ? 's' : '')); var errorPrompts = generateRuleHandlingPrompts(errorStats); return this._getUserViolationChoices(errorPrompts) .then(this._handleViolatedRules.bind(this, errorPrompts)) .then(function() { return this._config; }.bind(this)); }.bind(this)) |
| Branch IfStatement | |
|---|---|
| ✗ Positive was not executed (if) | if (!violatedRuleCount) { return this._config; } |
| ✓ Negative was executed (else) | if (!violatedRuleCount) { return this._config; }··· console.log(_path + ' violates ' + violatedRuleCount + ' rule' + (violatedRuleCount > 1 ? 's' : '')); |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | console.log(_path + ' violates ' + violatedRuleCount + ' rule' + (violatedRuleCount > 1 ? 's' : '')); |
| ✗ Negative was not returned (: ...) | console.log(_path + ' violates ' + violatedRuleCount + ' rule' + (violatedRuleCount > 1 ? 's' : '')); |
| Function (anonymous_283) | |
|---|---|
| ✗ Was not called | .then(function() {··· return this._config; }.bind(this)); |
| Function flushConfig | |
|---|---|
| ✗ Was not called | .then(function flushConfig() {··· fs.writeFileSync(process.cwd() + '/.jscsrc', JSON.stringify(this._config, null, '\t')); console.log('Generated a .jscsrc configuration file in ' + process.cwd()); }.bind(this)); |
| Function (anonymous_285) | |
|---|---|
| ✓ Was called | Generator.prototype._generateStatsForPresets = function(resultsPerPreset, presetNames) {··· return resultsPerPreset.map(function(presetResults, idx) { var errorCollection = [].concat.apply([], presetResults); var presetStats = { name: presetNames[idx], sum: 0, errors: [] }; errorCollection.forEach(function(error) { presetStats.sum += error.getErrorCount(); presetStats.errors = presetStats.errors.concat(error.getErrorList()); }); return presetStats; }); }; |
| Function (anonymous_286) | |
|---|---|
| ✓ Was called | return resultsPerPreset.map(function(presetResults, idx) {··· var errorCollection = [].concat.apply([], presetResults); var presetStats = { name: presetNames[idx], sum: 0, errors: [] }; errorCollection.forEach(function(error) { presetStats.sum += error.getErrorCount(); presetStats.errors = presetStats.errors.concat(error.getErrorList()); }); return presetStats; }); |
| Function (anonymous_287) | |
|---|---|
| ✓ Was called | errorCollection.forEach(function(error) {··· presetStats.sum += error.getErrorCount(); presetStats.errors = presetStats.errors.concat(error.getErrorList()); }); |
| Function (anonymous_288) | |
|---|---|
| ✓ Was called | Generator.prototype._showErrorCounts = function(statsForPresets) {··· var table = getTable(); statsForPresets.forEach(function(presetStats, idx) { table.push([idx + 1, presetStats.name, presetStats.sum, getUniqueErrorNames(presetStats.errors).length]); }); console.log(table.toString()); }; |
| Function (anonymous_289) | |
|---|---|
| ✓ Was called | statsForPresets.forEach(function(presetStats, idx) {··· table.push([idx + 1, presetStats.name, presetStats.sum, getUniqueErrorNames(presetStats.errors).length]); }); |
| Function (anonymous_290) | |
|---|---|
| ✓ Was called | Generator.prototype._getUserPresetChoice = function(prompt) {··· return this._showPrompt(prompt); }; |
| Function (anonymous_291) | |
|---|---|
| ✓ Was called | Generator.prototype._getUserViolationChoices = function(errorPrompts) {··· return this._showPrompt(errorPrompts); }; |
| Function (anonymous_292) | |
|---|---|
| ✗ Was not called | Generator.prototype._handleViolatedRules = function(errorPrompts, choices) {··· errorPrompts.forEach(function(errorPrompt) { var userChoice = choices[errorPrompt.name]; if (userChoice.toLowerCase() === 'e') { this._config[errorPrompt.associatedRuleName] = null; } }, this); }; |
| Function (anonymous_293) | |
|---|---|
| ✗ Was not called | errorPrompts.forEach(function(errorPrompt) {··· var userChoice = choices[errorPrompt.name]; if (userChoice.toLowerCase() === 'e') { this._config[errorPrompt.associatedRuleName] = null; } }, this); |
| Branch IfStatement | |
|---|---|
| ✗ Positive was not executed (if) | if (userChoice.toLowerCase() === 'e') {··· this._config[errorPrompt.associatedRuleName] = null; } |
| ✗ Negative was not executed (else) | }··· }, this); |
| Function (anonymous_294) | |
|---|---|
| ✓ Was called | Generator.prototype._checkAgainstPreset = function(path, presetName) {··· var checker = getChecker(); checker.configure({preset: presetName, maxErrors: Infinity}); return checker.checkPath(path); }; |
| Function getChecker | |
|---|---|
| ✓ Was called | function getChecker() {··· var checker = new Checker(); checker.registerDefaultRules(); return checker; } |
| Function generateRuleHandlingPrompts | |
|---|---|
| ✓ Was called | function generateRuleHandlingPrompts(errors) {··· // Generate list of rule names, sorted by violation count (descending) var violatedRuleNames = Object.keys(errors); violatedRuleNames.sort(function(a, b) { return errors[b].violations - errors[a].violations; }); return violatedRuleNames.map(function(ruleName) { var violationCount = errors[ruleName].violations; var fileCount = Object.keys(errors[ruleName].files).length; var prompt = assign({}, prompts[1]); prompt.associatedRuleName = ruleName; prompt.name = chalk.green(ruleName) + ' (' + violationCount + ' violation' + (violationCount > 1 ? 's' : '') + ' in ' + fileCount + ' file' + (fileCount > 1 ? 's' : '') + '):\n ' + prompt.name; return prompt; }); } |
| Function (anonymous_297) | |
|---|---|
| ✓ Was called | violatedRuleNames.sort(function(a, b) {··· return errors[b].violations - errors[a].violations; }); |
| Function (anonymous_298) | |
|---|---|
| ✓ Was called | return violatedRuleNames.map(function(ruleName) {··· var violationCount = errors[ruleName].violations; var fileCount = Object.keys(errors[ruleName].files).length; var prompt = assign({}, prompts[1]); prompt.associatedRuleName = ruleName; prompt.name = chalk.green(ruleName) + ' (' + violationCount + ' violation' + (violationCount > 1 ? 's' : '') + ' in ' + fileCount + ' file' + (fileCount > 1 ? 's' : '') + '):\n ' + prompt.name; return prompt; }); |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | ' (' + violationCount + ' violation' + (violationCount > 1 ? 's' : '') + |
| ✓ Negative was returned (: ...) | ' (' + violationCount + ' violation' + (violationCount > 1 ? 's' : '') + |
| Branch ConditionalExpression | |
|---|---|
| ✗ Positive was not returned (? ...) | ' in ' + fileCount + ' file' + (fileCount > 1 ? 's' : '') + '):\n ' + |
| ✓ Negative was returned (: ...) | ' in ' + fileCount + ' file' + (fileCount > 1 ? 's' : '') + '):\n ' + |
| Function getErrorsByRuleName | |
|---|---|
| ✓ Was called | function getErrorsByRuleName(errorsList) {··· var errors = {}; errorsList.forEach(function(error) { var rulename = error.rule; errors[rulename] = errors[rulename] || { files: {}, violations: 0 }; errors[rulename].violations += 1; errors[rulename].files[error.filename] = true; }); return errors; } |
| Function (anonymous_300) | |
|---|---|
| ✓ Was called | errorsList.forEach(function(error) {··· var rulename = error.rule; errors[rulename] = errors[rulename] || { files: {}, violations: 0 }; errors[rulename].violations += 1; errors[rulename].files[error.filename] = true; }); |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | errors[rulename] = errors[rulename] || {··· files: {}, violations: 0 }; |
| ✓ Was returned | errors[rulename] = errors[rulename] || { |
| Function getUniqueErrorNames | |
|---|---|
| ✓ Was called | function getUniqueErrorNames(errorsList) {··· var errorNameLUT = {}; errorsList.forEach(function(error) { errorNameLUT[error.rule] = true; }); return Object.keys(errorNameLUT); } |
| Function (anonymous_302) | |
|---|---|
| ✓ Was called | errorsList.forEach(function(error) {··· errorNameLUT[error.rule] = true; }); |
| Function getTable | |
|---|---|
| ✓ Was called | function getTable() {··· return new Table({ chars: { top: '', 'top-mid': '', 'top-left': '', 'top-right': '', bottom: '', 'bottom-mid': '', 'bottom-left': '', 'bottom-right': '', left: '', 'left-mid': '', mid: '', 'mid-mid': '', right: '', 'right-mid': '' , middle: ' ' }, style: { 'padding-left': 0, 'padding-right': 0 }, head: ['', 'Preset', '#Errors', '#Rules'] }); } |
| Function (anonymous_304) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_305) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_306) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowAnonymousFunctions'; }, |
| Function (anonymous_307) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType(['FunctionExpression', 'FunctionDeclaration'], function(node) { if (node.id === null) { errors.add('Anonymous functions need to be named', node.loc.start); } }); } |
| Function (anonymous_308) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['FunctionExpression', 'FunctionDeclaration'], function(node) {··· if (node.id === null) { errors.add('Anonymous functions need to be named', node.loc.start); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.id === null) {··· errors.add('Anonymous functions need to be named', node.loc.start); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_309) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_310) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_311) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowArrayDestructuringReturn'; }, |
| Function (anonymous_312) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var addError = function(node) { errors.add( 'Array destructuring is not allowed for return, ' + 'use object destructuring instead', node.loc.start ); }; var isViolationDetected = function(maybeArrayPattern, maybeCallExpression) { return maybeCallExpression && maybeCallExpression.type === 'CallExpression' && maybeArrayPattern && maybeArrayPattern.type === 'ArrayPattern'; }; file.iterateNodesByType(['VariableDeclaration', 'AssignmentExpression'], function(node) { if (node.type === 'VariableDeclaration') { node.declarations.forEach(function(declaration) { if (!isViolationDetected(declaration.id, declaration.init)) { return; } addError(declaration.init); }); } if (node.type === 'AssignmentExpression') { if (!isViolationDetected(node.left, node.right)) { return; } addError(node.right); } }); } |
| Function (anonymous_313) | |
|---|---|
| ✓ Was called | var addError = function(node) {··· errors.add( 'Array destructuring is not allowed for return, ' + 'use object destructuring instead', node.loc.start ); }; |
| Function (anonymous_314) | |
|---|---|
| ✓ Was called | var isViolationDetected = function(maybeArrayPattern, maybeCallExpression) {··· return maybeCallExpression && maybeCallExpression.type === 'CallExpression' && maybeArrayPattern && maybeArrayPattern.type === 'ArrayPattern'; }; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | maybeArrayPattern && maybeArrayPattern.type === 'ArrayPattern'; |
| ✗ Was not returned | return maybeCallExpression && maybeCallExpression.type === 'CallExpression' &&··· maybeArrayPattern && maybeArrayPattern.type === 'ArrayPattern'; |
| Branch LogicalExpression | |
| ✓ Was returned | maybeArrayPattern && maybeArrayPattern.type === 'ArrayPattern'; |
| ✗ Was not returned | return maybeCallExpression && maybeCallExpression.type === 'CallExpression' && |
| Branch LogicalExpression | |
| ✓ Was returned | return maybeCallExpression && maybeCallExpression.type === 'CallExpression' && |
| ✗ Was not returned | return maybeCallExpression && maybeCallExpression.type === 'CallExpression' && |
| Function (anonymous_315) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['VariableDeclaration', 'AssignmentExpression'], function(node) {··· if (node.type === 'VariableDeclaration') { node.declarations.forEach(function(declaration) { if (!isViolationDetected(declaration.id, declaration.init)) { return; } addError(declaration.init); }); } if (node.type === 'AssignmentExpression') { if (!isViolationDetected(node.left, node.right)) { return; } addError(node.right); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.type === 'VariableDeclaration') {··· node.declarations.forEach(function(declaration) { if (!isViolationDetected(declaration.id, declaration.init)) { return; } addError(declaration.init); }); } |
| ✓ Negative was executed (else) | }··· if (node.type === 'AssignmentExpression') { |
| Function (anonymous_316) | |
|---|---|
| ✓ Was called | node.declarations.forEach(function(declaration) {··· if (!isViolationDetected(declaration.id, declaration.init)) { return; } addError(declaration.init); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!isViolationDetected(declaration.id, declaration.init)) {··· return; } |
| ✓ Negative was executed (else) | }··· addError(declaration.init); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.type === 'AssignmentExpression') {··· if (!isViolationDetected(node.left, node.right)) { return; } addError(node.right); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!isViolationDetected(node.left, node.right)) {··· return; } |
| ✓ Negative was executed (else) | }··· addError(node.right); |
| Function (anonymous_317) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_318) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_319) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowArrowFunctions'; }, |
| Function (anonymous_320) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType(['ArrowFunctionExpression'], function(node) { errors.add('Do not use arrow functions', node.loc.start); }); } |
| Function (anonymous_321) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['ArrowFunctionExpression'], function(node) {··· errors.add('Do not use arrow functions', node.loc.start); }); |
| Function (anonymous_322) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_323) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_324) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowCapitalizedComments'; }, |
| Function (anonymous_325) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var letterPattern = require('../../patterns/L'); var lowerCasePattern = require('../../patterns/Ll'); file.iterateTokensByType(['Line', 'Block'], function(comment) { var stripped = comment.value.replace(/[\n\s\*]/g, ''); var firstChar = stripped[0]; if (letterPattern.test(firstChar) && !lowerCasePattern.test(firstChar)) { errors.add( 'Comments must start with a lowercase letter', comment.loc.start ); } }); } |
| Function (anonymous_326) | |
|---|---|
| ✓ Was called | file.iterateTokensByType(['Line', 'Block'], function(comment) {··· var stripped = comment.value.replace(/[\n\s\*]/g, ''); var firstChar = stripped[0]; if (letterPattern.test(firstChar) && !lowerCasePattern.test(firstChar)) { errors.add( 'Comments must start with a lowercase letter', comment.loc.start ); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (letterPattern.test(firstChar) && !lowerCasePattern.test(firstChar)) {··· errors.add( 'Comments must start with a lowercase letter', comment.loc.start ); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | if (letterPattern.test(firstChar) && !lowerCasePattern.test(firstChar)) { |
| ✓ Was returned | if (letterPattern.test(firstChar) && !lowerCasePattern.test(firstChar)) { |
| Function (anonymous_327) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_328) | |
|---|---|
| ✓ Was called | configure: function(options) {··· var optionName = this.getOptionName(); if (typeof options !== 'object') { assert( options === true, optionName + ' option requires either a true value or an object' ); var _options = {allExcept: []}; return this.configure(_options); } assert( Array.isArray(options.allExcept), 'Property `allExcept` in ' + optionName + ' should be an array of strings' ); this._exceptFunction = options.allExcept.indexOf('function') > -1; }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof options !== 'object') {··· assert( options === true, optionName + ' option requires either a true value or an object' ); var _options = {allExcept: []}; return this.configure(_options); } |
| ✓ Negative was executed (else) | }··· assert( |
| Function (anonymous_329) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowCommaBeforeLineBreak'; }, |
| Function (anonymous_330) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var exceptFunction = this._exceptFunction; function canSkip(token) { var node = file.getNodeByRange(token.range[0]); if (node.loc.start.line === node.loc.end.line) { return true; } // exception for function params if (node.params && node.params[0].loc.start.line === node.params[node.params.length - 1].loc.end.line) { return true; } // See #1841 if (!exceptFunction || !node.properties) { return false; } return node.properties.some(function(property) { return property.value.type === 'FunctionExpression'; }); } file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { var nextToken = file.getNextToken(token); if (canSkip(token) || nextToken.value === ',') { return; } errors.assert.sameLine({ token: token, nextToken: nextToken, message: 'Commas should be placed on the same line as value' }); errors.assert.differentLine({ token: file.getPrevToken(token), nextToken: token, message: 'Commas should be placed on new line' }); }); } |
| Function canSkip | |
|---|---|
| ✓ Was called | function canSkip(token) {··· var node = file.getNodeByRange(token.range[0]); if (node.loc.start.line === node.loc.end.line) { return true; } // exception for function params if (node.params && node.params[0].loc.start.line === node.params[node.params.length - 1].loc.end.line) { return true; } // See #1841 if (!exceptFunction || !node.properties) { return false; } return node.properties.some(function(property) { return property.value.type === 'FunctionExpression'; }); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.loc.start.line === node.loc.end.line) {··· return true; } |
| ✓ Negative was executed (else) | }··· // exception for function params |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | node.params[0].loc.start.line === node.params[node.params.length - 1].loc.end.line) {··· return true; } |
| ✓ Negative was executed (else) | }··· // See #1841 |
| Branch LogicalExpression | |
| ✓ Was returned | node.params[0].loc.start.line === node.params[node.params.length - 1].loc.end.line) { |
| ✓ Was returned | if (node.params && |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!exceptFunction || !node.properties) {··· return false; } |
| ✓ Negative was executed (else) | }··· return node.properties.some(function(property) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (!exceptFunction || !node.properties) { |
| ✓ Was returned | if (!exceptFunction || !node.properties) { |
| Function (anonymous_332) | |
|---|---|
| ✓ Was called | return node.properties.some(function(property) {··· return property.value.type === 'FunctionExpression'; }); |
| Function (anonymous_333) | |
|---|---|
| ✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) {··· var nextToken = file.getNextToken(token); if (canSkip(token) || nextToken.value === ',') { return; } errors.assert.sameLine({ token: token, nextToken: nextToken, message: 'Commas should be placed on the same line as value' }); errors.assert.differentLine({ token: file.getPrevToken(token), nextToken: token, message: 'Commas should be placed on new line' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (canSkip(token) || nextToken.value === ',') {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.sameLine({ |
| Branch LogicalExpression | |
| ✓ Was returned | if (canSkip(token) || nextToken.value === ',') { |
| ✓ Was returned | if (canSkip(token) || nextToken.value === ',') { |
| Function (anonymous_334) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_335) | |
|---|---|
| ✓ Was called | configure: function(statementTypes) {··· assert( Array.isArray(statementTypes) || statementTypes === true, this.getOptionName() + ' option requires array or true value' ); if (statementTypes === true) { statementTypes = defaultKeywords; } this._typeIndex = {}; statementTypes.forEach(function(type) { this._typeIndex[type] = true; }.bind(this)); }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | Array.isArray(statementTypes) || statementTypes === true, |
| ✓ Was returned | Array.isArray(statementTypes) || statementTypes === true, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (statementTypes === true) {··· statementTypes = defaultKeywords; } |
| ✓ Negative was executed (else) | }··· this._typeIndex = {}; |
| Function (anonymous_336) | |
|---|---|
| ✓ Was called | statementTypes.forEach(function(type) {··· this._typeIndex[type] = true; }.bind(this)); |
| Function (anonymous_337) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowCurlyBraces'; }, |
| Function (anonymous_338) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· function isSingleBlockStatement(node) { return node && node.type === 'BlockStatement' && node.body.length === 1; } function addError(typeString, entity) { errors.add( typeString + ' statement with extra curly braces', entity.loc.start.line, entity.loc.start.column ); } function checkBody(type, typeString) { file.iterateNodesByType(type, function(node) { if (isSingleBlockStatement(node.body)) { addError(typeString, node); } }); } var typeIndex = this._typeIndex; if (typeIndex.if || typeIndex.else) { file.iterateNodesByType('IfStatement', function(node) { if (typeIndex.if && isSingleBlockStatement(node.consequent)) { addError('If', node); } if (typeIndex.else && isSingleBlockStatement(node.alternate)) { addError('Else', file.getPrevToken(file.getFirstNodeToken(node.alternate))); } }); } if (typeIndex.while) { checkBody('WhileStatement', 'While'); } if (typeIndex.for) { checkBody('ForStatement', 'For'); checkBody('ForInStatement', 'For in'); checkBody('ForOfStatement', 'For of'); } if (typeIndex.do) { checkBody('DoWhileStatement', 'Do while'); } if (typeIndex.with) { checkBody('WithStatement', 'With'); } } |
| Function isSingleBlockStatement | |
|---|---|
| ✓ Was called | function isSingleBlockStatement(node) {··· return node && node.type === 'BlockStatement' && node.body.length === 1; } |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | node.body.length === 1; |
| ✓ Was returned | return node && node.type === 'BlockStatement' && |
| Branch LogicalExpression | |
| ✓ Was returned | return node && node.type === 'BlockStatement' && |
| ✓ Was returned | return node && node.type === 'BlockStatement' && |
| Function addError | |
|---|---|
| ✓ Was called | function addError(typeString, entity) {··· errors.add( typeString + ' statement with extra curly braces', entity.loc.start.line, entity.loc.start.column ); } |
| Function checkBody | |
|---|---|
| ✓ Was called | function checkBody(type, typeString) {··· file.iterateNodesByType(type, function(node) { if (isSingleBlockStatement(node.body)) { addError(typeString, node); } }); } |
| Function (anonymous_342) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(type, function(node) {··· if (isSingleBlockStatement(node.body)) { addError(typeString, node); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isSingleBlockStatement(node.body)) {··· addError(typeString, node); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeIndex.if || typeIndex.else) {··· file.iterateNodesByType('IfStatement', function(node) { if (typeIndex.if && isSingleBlockStatement(node.consequent)) { addError('If', node); } if (typeIndex.else && isSingleBlockStatement(node.alternate)) { addError('Else', file.getPrevToken(file.getFirstNodeToken(node.alternate))); } }); } |
| ✓ Negative was executed (else) | }··· if (typeIndex.while) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (typeIndex.if || typeIndex.else) { |
| ✓ Was returned | if (typeIndex.if || typeIndex.else) { |
| Function (anonymous_343) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('IfStatement', function(node) {··· if (typeIndex.if && isSingleBlockStatement(node.consequent)) { addError('If', node); } if (typeIndex.else && isSingleBlockStatement(node.alternate)) { addError('Else', file.getPrevToken(file.getFirstNodeToken(node.alternate))); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeIndex.if && isSingleBlockStatement(node.consequent)) {··· addError('If', node); } |
| ✓ Negative was executed (else) | }··· if (typeIndex.else && isSingleBlockStatement(node.alternate)) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (typeIndex.if && isSingleBlockStatement(node.consequent)) { |
| ✓ Was returned | if (typeIndex.if && isSingleBlockStatement(node.consequent)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeIndex.else && isSingleBlockStatement(node.alternate)) {··· addError('Else', file.getPrevToken(file.getFirstNodeToken(node.alternate))); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | if (typeIndex.else && isSingleBlockStatement(node.alternate)) { |
| ✓ Was returned | if (typeIndex.else && isSingleBlockStatement(node.alternate)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeIndex.while) {··· checkBody('WhileStatement', 'While'); } |
| ✓ Negative was executed (else) | }··· if (typeIndex.for) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeIndex.for) {··· checkBody('ForStatement', 'For'); checkBody('ForInStatement', 'For in'); checkBody('ForOfStatement', 'For of'); } |
| ✓ Negative was executed (else) | }··· if (typeIndex.do) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeIndex.do) {··· checkBody('DoWhileStatement', 'Do while'); } |
| ✓ Negative was executed (else) | }··· if (typeIndex.with) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeIndex.with) {··· checkBody('WithStatement', 'With'); } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_344) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_345) | |
|---|---|
| ✓ Was called | configure: function(identifiers) {··· assert( identifiers === true || typeof identifiers === 'object', this.getOptionName() + ' option requires the value `true` ' + 'or an object with String[] `allExcept` property' ); // verify first item in `allExcept` property in object (if it's an object) assert( typeof identifiers !== 'object' || Array.isArray(identifiers.allExcept) && typeof identifiers.allExcept[0] === 'string', 'Property `allExcept` in ' + this.getOptionName() + ' should be an array of strings' ); var isTrue = identifiers === true; var defaultIdentifiers = [ '__proto__', '_', '__dirname', '__filename', 'super_' ]; if (isTrue) { identifiers = defaultIdentifiers; } else { identifiers = (identifiers.allExcept).concat(defaultIdentifiers); } this._identifierIndex = identifiers; }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | typeof identifiers === 'object', |
| ✓ Was returned | identifiers === true || |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | Array.isArray(identifiers.allExcept) &&··· typeof identifiers.allExcept[0] === 'string', |
| ✓ Was returned | typeof identifiers !== 'object' || |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | typeof identifiers.allExcept[0] === 'string', |
| ✓ Was returned | Array.isArray(identifiers.allExcept) && |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isTrue) {··· identifiers = defaultIdentifiers; } else { |
| ✓ Negative was executed (else) | } else {··· identifiers = (identifiers.allExcept).concat(defaultIdentifiers); } |
| Function (anonymous_346) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowDanglingUnderscores'; }, |
| Function (anonymous_347) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var allowedIdentifiers = this._identifierIndex; file.iterateTokensByType('Identifier', function(token) { var value = token.value; if ((value[0] === '_' || value.slice(-1) === '_') && allowedIdentifiers.indexOf(value) < 0 ) { errors.add( 'Invalid dangling underscore found', token.loc.start.line, token.loc.start.column ); } }); } |
| Function (anonymous_348) | |
|---|---|
| ✓ Was called | file.iterateTokensByType('Identifier', function(token) {··· var value = token.value; if ((value[0] === '_' || value.slice(-1) === '_') && allowedIdentifiers.indexOf(value) < 0 ) { errors.add( 'Invalid dangling underscore found', token.loc.start.line, token.loc.start.column ); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | ) {··· errors.add( 'Invalid dangling underscore found', token.loc.start.line, token.loc.start.column ); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | allowedIdentifiers.indexOf(value) < 0 |
| ✓ Was returned | if ((value[0] === '_' || value.slice(-1) === '_') && |
| Branch LogicalExpression | |
| ✓ Was returned | if ((value[0] === '_' || value.slice(-1) === '_') && |
| ✓ Was returned | if ((value[0] === '_' || value.slice(-1) === '_') && |
| Function (anonymous_349) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_350) | |
|---|---|
| ✓ Was called | configure: function(options) {··· var optionName = this.getOptionName(); if (typeof options !== 'object') { assert( options === true, optionName + ' option requires a true value or an object like: { allExcept: [\'comments\'] }' ); var _options = { allExcept: [] }; return this.configure(_options); } assert( Array.isArray(options.allExcept), 'Property `allExcept` in ' + optionName + ' should be an array of strings' ); this._exceptComments = options.allExcept.indexOf('comments') > -1; }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof options !== 'object') {··· assert( options === true, optionName + ' option requires a true value or an object like: { allExcept: [\'comments\'] }' ); var _options = { allExcept: [] }; return this.configure(_options); } |
| ✓ Negative was executed (else) | }··· assert( |
| Function (anonymous_351) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowEmptyBlocks'; }, |
| Function (anonymous_352) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var exceptComments = this._exceptComments; function canSkip(token) { if (!exceptComments) { return false; } var canSkipToken = false; file.getComments().forEach(function(comment) { if (comment.loc.start.line >= token.loc.start.line && comment.loc.end.line <= token.loc.end.line) { canSkipToken = true; } }); return canSkipToken; } file.iterateNodesByType('BlockStatement', function(node) { if (node.body.length) { return true; } if (canSkip(node)) { return true; } if (node.parentNode.type !== 'CatchClause' && node.parentNode.type !== 'FunctionDeclaration' && node.parentNode.type !== 'FunctionExpression' && node.parentNode.type !== 'ArrowFunctionExpression') { errors.add('Empty block found', node.loc.end); } }); } |
| Function canSkip | |
|---|---|
| ✓ Was called | function canSkip(token) {··· if (!exceptComments) { return false; } var canSkipToken = false; file.getComments().forEach(function(comment) { if (comment.loc.start.line >= token.loc.start.line && comment.loc.end.line <= token.loc.end.line) { canSkipToken = true; } }); return canSkipToken; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!exceptComments) {··· return false; } |
| ✓ Negative was executed (else) | }··· var canSkipToken = false; |
| Function (anonymous_354) | |
|---|---|
| ✓ Was called | file.getComments().forEach(function(comment) {··· if (comment.loc.start.line >= token.loc.start.line && comment.loc.end.line <= token.loc.end.line) { canSkipToken = true; } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | comment.loc.end.line <= token.loc.end.line) {··· canSkipToken = true; } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | comment.loc.end.line <= token.loc.end.line) { |
| ✓ Was returned | if (comment.loc.start.line >= token.loc.start.line && |
| Function (anonymous_355) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('BlockStatement', function(node) {··· if (node.body.length) { return true; } if (canSkip(node)) { return true; } if (node.parentNode.type !== 'CatchClause' && node.parentNode.type !== 'FunctionDeclaration' && node.parentNode.type !== 'FunctionExpression' && node.parentNode.type !== 'ArrowFunctionExpression') { errors.add('Empty block found', node.loc.end); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.body.length) {··· return true; } |
| ✓ Negative was executed (else) | }··· if (canSkip(node)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (canSkip(node)) {··· return true; } |
| ✓ Negative was executed (else) | }··· if (node.parentNode.type !== 'CatchClause' && |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | node.parentNode.type !== 'ArrowFunctionExpression') {··· errors.add('Empty block found', node.loc.end); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | node.parentNode.type !== 'ArrowFunctionExpression') { |
| ✓ Was returned | if (node.parentNode.type !== 'CatchClause' &&··· node.parentNode.type !== 'FunctionDeclaration' && node.parentNode.type !== 'FunctionExpression' && |
| Branch LogicalExpression | |
| ✓ Was returned | node.parentNode.type !== 'FunctionExpression' && |
| ✓ Was returned | if (node.parentNode.type !== 'CatchClause' &&··· node.parentNode.type !== 'FunctionDeclaration' && |
| Branch LogicalExpression | |
| ✓ Was returned | node.parentNode.type !== 'FunctionDeclaration' && |
| ✓ Was returned | if (node.parentNode.type !== 'CatchClause' && |
| Function (anonymous_356) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_357) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_358) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowFunctionDeclarations'; }, |
| Function (anonymous_359) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('FunctionDeclaration', function(node) { errors.add('Illegal function declaration', node.loc.start); }); } |
| Function (anonymous_360) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('FunctionDeclaration', function(node) {··· errors.add('Illegal function declaration', node.loc.start); }); |
| Function (anonymous_361) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_362) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_363) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowIdenticalDestructuringNames'; }, |
| Function (anonymous_364) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType(['ObjectPattern'], function(node) { var props = node.properties; for (var i = 0; i < props.length; i++) { var prop = props[i]; if (prop.type === 'Property' && !prop.shorthand && !prop.computed && prop.key.name === prop.value.name) { errors.add('Use the shorthand form of destructuring instead', prop.loc.start); } } }); } |
| Function (anonymous_365) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['ObjectPattern'], function(node) {··· var props = node.properties; for (var i = 0; i < props.length; i++) { var prop = props[i]; if (prop.type === 'Property' && !prop.shorthand && !prop.computed && prop.key.name === prop.value.name) { errors.add('Use the shorthand form of destructuring instead', prop.loc.start); } } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | prop.key.name === prop.value.name) {··· errors.add('Use the shorthand form of destructuring instead', prop.loc.start); } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | prop.key.name === prop.value.name) { |
| ✓ Was returned | if (prop.type === 'Property' && !prop.shorthand && !prop.computed && |
| Branch LogicalExpression | |
| ✓ Was returned | if (prop.type === 'Property' && !prop.shorthand && !prop.computed && |
| ✓ Was returned | if (prop.type === 'Property' && !prop.shorthand && !prop.computed && |
| Branch LogicalExpression | |
| ✓ Was returned | if (prop.type === 'Property' && !prop.shorthand && !prop.computed && |
| ✗ Was not returned | if (prop.type === 'Property' && !prop.shorthand && !prop.computed && |
| Function (anonymous_366) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_367) | |
|---|---|
| ✓ Was called | configure: function(identifiers) {··· assert( Array.isArray(identifiers), 'disallowIdentifierNames option requires an array' ); this._identifierIndex = {}; for (var i = 0, l = identifiers.length; i < l; i++) { this._identifierIndex[identifiers[i]] = true; } }, |
| Function (anonymous_368) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowIdentifierNames'; }, |
| Function (anonymous_369) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var disallowedIdentifiers = this._identifierIndex; file.iterateNodesByType('Identifier', function(node) { if (Object.prototype.hasOwnProperty.call(disallowedIdentifiers, node.name)) { errors.add('Illegal Identifier name: ' + node.name, node.loc.start); } }); file.iterateNodesByType('MemberExpression', function(node) { if (node.property.type === 'Literal') { if (Object.prototype.hasOwnProperty.call(disallowedIdentifiers, node.property.value)) { errors.add('Illegal Identifier name: ' + node.property.value, node.property.loc.start); } } }); } |
| Function (anonymous_370) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('Identifier', function(node) {··· if (Object.prototype.hasOwnProperty.call(disallowedIdentifiers, node.name)) { errors.add('Illegal Identifier name: ' + node.name, node.loc.start); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (Object.prototype.hasOwnProperty.call(disallowedIdentifiers, node.name)) {··· errors.add('Illegal Identifier name: ' + node.name, node.loc.start); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_371) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('MemberExpression', function(node) {··· if (node.property.type === 'Literal') { if (Object.prototype.hasOwnProperty.call(disallowedIdentifiers, node.property.value)) { errors.add('Illegal Identifier name: ' + node.property.value, node.property.loc.start); } } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.property.type === 'Literal') {··· if (Object.prototype.hasOwnProperty.call(disallowedIdentifiers, node.property.value)) { errors.add('Illegal Identifier name: ' + node.property.value, node.property.loc.start); } } |
| ✓ Negative was executed (else) | }··· }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (Object.prototype.hasOwnProperty.call(disallowedIdentifiers, node.property.value)) {··· errors.add('Illegal Identifier name: ' + node.property.value, node.property.loc.start); } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_372) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_373) | |
|---|---|
| ✓ Was called | configure: function(types) {··· assert(Array.isArray(types), this.getOptionName() + ' option requires array value'); this._typeIndex = {}; for (var i = 0, l = types.length; i < l; i++) { this._typeIndex[types[i]] = true; } }, |
| Function (anonymous_374) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowImplicitTypeConversion'; }, |
| Function (anonymous_375) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var types = this._typeIndex; if (types.numeric || types.boolean || types.binary) { file.iterateNodesByType('UnaryExpression', function(node) { if (types.numeric && node.operator === '+') { errors.add('Implicit numeric conversion', node.loc.start); } if (types.binary && node.operator === '~') { errors.add('Implicit binary conversion', node.loc.start); } if (types.boolean && node.operator === '!' && node.argument.type === 'UnaryExpression' && node.argument.operator === '!' ) { errors.add('Implicit boolean conversion', node.loc.start); } }); } if (types.string) { file.iterateNodesByType('BinaryExpression', function(node) { if (node.operator !== '+') { return; } // Do not report concatination for same string literals (#1538) if (node.left.type === node.right.type) { return; } if ( (node.left.type === 'Literal' && node.left.value === '') || (node.right.type === 'Literal' && node.right.value === '') ) { errors.add('Implicit string conversion', node.loc.start); } }); } } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (types.numeric || types.boolean || types.binary) {··· file.iterateNodesByType('UnaryExpression', function(node) { if (types.numeric && node.operator === '+') { errors.add('Implicit numeric conversion', node.loc.start); } if (types.binary && node.operator === '~') { errors.add('Implicit binary conversion', node.loc.start); } if (types.boolean && node.operator === '!' && node.argument.type === 'UnaryExpression' && node.argument.operator === '!' ) { errors.add('Implicit boolean conversion', node.loc.start); } }); } |
| ✓ Negative was executed (else) | }··· if (types.string) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (types.numeric || types.boolean || types.binary) { |
| ✓ Was returned | if (types.numeric || types.boolean || types.binary) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (types.numeric || types.boolean || types.binary) { |
| ✓ Was returned | if (types.numeric || types.boolean || types.binary) { |
| Function (anonymous_376) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('UnaryExpression', function(node) {··· if (types.numeric && node.operator === '+') { errors.add('Implicit numeric conversion', node.loc.start); } if (types.binary && node.operator === '~') { errors.add('Implicit binary conversion', node.loc.start); } if (types.boolean && node.operator === '!' && node.argument.type === 'UnaryExpression' && node.argument.operator === '!' ) { errors.add('Implicit boolean conversion', node.loc.start); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (types.numeric && node.operator === '+') {··· errors.add('Implicit numeric conversion', node.loc.start); } |
| ✓ Negative was executed (else) | }··· if (types.binary && node.operator === '~') { |
| Branch LogicalExpression | |
| ✓ Was returned | if (types.numeric && node.operator === '+') { |
| ✓ Was returned | if (types.numeric && node.operator === '+') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (types.binary && node.operator === '~') {··· errors.add('Implicit binary conversion', node.loc.start); } |
| ✓ Negative was executed (else) | }··· if (types.boolean && |
| Branch LogicalExpression | |
| ✓ Was returned | if (types.binary && node.operator === '~') { |
| ✓ Was returned | if (types.binary && node.operator === '~') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | ) {··· errors.add('Implicit boolean conversion', node.loc.start); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | node.argument.operator === '!' |
| ✓ Was returned | if (types.boolean &&··· node.operator === '!' && node.argument.type === 'UnaryExpression' && |
| Branch LogicalExpression | |
| ✓ Was returned | node.argument.type === 'UnaryExpression' && |
| ✓ Was returned | if (types.boolean &&··· node.operator === '!' && |
| Branch LogicalExpression | |
| ✓ Was returned | node.operator === '!' && |
| ✓ Was returned | if (types.boolean && |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (types.string) {··· file.iterateNodesByType('BinaryExpression', function(node) { if (node.operator !== '+') { return; } // Do not report concatination for same string literals (#1538) if (node.left.type === node.right.type) { return; } if ( (node.left.type === 'Literal' && node.left.value === '') || (node.right.type === 'Literal' && node.right.value === '') ) { errors.add('Implicit string conversion', node.loc.start); } }); } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_377) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('BinaryExpression', function(node) {··· if (node.operator !== '+') { return; } // Do not report concatination for same string literals (#1538) if (node.left.type === node.right.type) { return; } if ( (node.left.type === 'Literal' && node.left.value === '') || (node.right.type === 'Literal' && node.right.value === '') ) { errors.add('Implicit string conversion', node.loc.start); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.operator !== '+') {··· return; } |
| ✓ Negative was executed (else) | }··· // Do not report concatination for same string literals (#1538) |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.left.type === node.right.type) {··· return; } |
| ✓ Negative was executed (else) | }··· if ( |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | ) {··· errors.add('Implicit string conversion', node.loc.start); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | (node.right.type === 'Literal' && node.right.value === '') |
| ✓ Was returned | (node.left.type === 'Literal' && node.left.value === '') || |
| Branch LogicalExpression | |
| ✓ Was returned | (node.left.type === 'Literal' && node.left.value === '') || |
| ✓ Was returned | (node.left.type === 'Literal' && node.left.value === '') || |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | (node.right.type === 'Literal' && node.right.value === '') |
| ✓ Was returned | (node.right.type === 'Literal' && node.right.value === '') |
| Function getCommentErrors | |
|---|---|
| ✓ Was called | function getCommentErrors(comment, keywordRegEx) {··· var splitComment = comment.value.split('\n'); var errors = []; splitComment.forEach(function(commentNode, index) { var lineIndex = index; var matches = commentNode.match(keywordRegEx); var lastIndex = -1; if (!matches) { return; } errors = errors.concat(matches.map(function(match) { lastIndex++; lastIndex = commentNode.indexOf(match, lastIndex); // line + lineIndex because comment block was split at new lines // will place carat at correct place within multiline comment // foundAtIndex += 2 because comment opening is stripped // +2 finds accurate carat position on opening line comment return { line: comment.loc.start.line + lineIndex, column: lastIndex + (lineIndex > 0 ? 0 : 2) }; })); }); return errors; } |
| Function (anonymous_379) | |
|---|---|
| ✓ Was called | splitComment.forEach(function(commentNode, index) {··· var lineIndex = index; var matches = commentNode.match(keywordRegEx); var lastIndex = -1; if (!matches) { return; } errors = errors.concat(matches.map(function(match) { lastIndex++; lastIndex = commentNode.indexOf(match, lastIndex); // line + lineIndex because comment block was split at new lines // will place carat at correct place within multiline comment // foundAtIndex += 2 because comment opening is stripped // +2 finds accurate carat position on opening line comment return { line: comment.loc.start.line + lineIndex, column: lastIndex + (lineIndex > 0 ? 0 : 2) }; })); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!matches) { return; } |
| ✓ Negative was executed (else) | if (!matches) { return; }··· errors = errors.concat(matches.map(function(match) { |
| Function (anonymous_380) | |
|---|---|
| ✓ Was called | errors = errors.concat(matches.map(function(match) {··· lastIndex++; lastIndex = commentNode.indexOf(match, lastIndex); // line + lineIndex because comment block was split at new lines // will place carat at correct place within multiline comment // foundAtIndex += 2 because comment opening is stripped // +2 finds accurate carat position on opening line comment return { line: comment.loc.start.line + lineIndex, column: lastIndex + (lineIndex > 0 ? 0 : 2) }; })); |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | column: lastIndex + (lineIndex > 0 ? 0 : 2) |
| ✓ Negative was returned (: ...) | column: lastIndex + (lineIndex > 0 ? 0 : 2) |
| Function (anonymous_381) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_382) | |
|---|---|
| ✓ Was called | configure: function(keywords) {··· this._message = 'Comments cannot contain the following keywords: '; this._keywords = ['todo', 'fixme']; switch (true) { case Array.isArray(keywords): // use the array of strings provided to build RegExp pattern this._keywords = keywords; /* falls through */ case keywords: // use default keywords this._message += this._keywords.join(', '); this._keywordRegEx = new RegExp('\\b(' + this._keywords.join('|') + ')\\b', 'gi'); break; case typeof keywords === 'string': // use string passed in as the RegExp pattern this._message = 'Comments cannot contain keywords based on the expression you provided'; this._keywordRegEx = new RegExp(keywords, 'gi'); break; default: assert(false, this.getOptionName() + ' option requires a true value, a string or an array'); } }, |
| Branch SwitchStatement | |
|---|---|
| ✓ Was evaluated | case Array.isArray(keywords):··· // use the array of strings provided to build RegExp pattern this._keywords = keywords; |
| ✓ Was evaluated | case keywords:··· // use default keywords this._message += this._keywords.join(', '); this._keywordRegEx = new RegExp('\\b(' + this._keywords.join('|') + ')\\b', 'gi'); break; |
| ✓ Was evaluated | case typeof keywords === 'string':··· // use string passed in as the RegExp pattern this._message = 'Comments cannot contain keywords based on the expression you provided'; this._keywordRegEx = new RegExp(keywords, 'gi'); break; |
| ✓ Was evaluated | default:··· assert(false, this.getOptionName() + ' option requires a true value, a string or an array'); |
| Function (anonymous_383) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowKeywordsInComments'; }, |
| Function (anonymous_384) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateTokensByType(['Line', 'Block'], function(comment) { getCommentErrors(comment, this._keywordRegEx).forEach(function(errorObj) { errors.add(this._message, errorObj); }.bind(this)); }.bind(this)); } |
| Function (anonymous_385) | |
|---|---|
| ✓ Was called | file.iterateTokensByType(['Line', 'Block'], function(comment) {··· getCommentErrors(comment, this._keywordRegEx).forEach(function(errorObj) { errors.add(this._message, errorObj); }.bind(this)); }.bind(this)); |
| Function (anonymous_386) | |
|---|---|
| ✓ Was called | getCommentErrors(comment, this._keywordRegEx).forEach(function(errorObj) {··· errors.add(this._message, errorObj); }.bind(this)); |
| Function isPreviousTokenAComment | |
|---|---|
| ✓ Was called | function isPreviousTokenAComment(token, file) {··· var prevToken = file.getPrevToken(token, {includeComments: true}); return (prevToken.type === 'Line' || prevToken.type === 'Block'); } |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | return (prevToken.type === 'Line' || prevToken.type === 'Block'); |
| ✓ Was returned | return (prevToken.type === 'Line' || prevToken.type === 'Block'); |
| Function (anonymous_388) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_389) | |
|---|---|
| ✓ Was called | configure: function(keywords) {··· assert(Array.isArray(keywords), this.getOptionName() + ' option requires array value'); this._keywords = keywords; }, |
| Function (anonymous_390) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowKeywordsOnNewLine'; }, |
| Function (anonymous_391) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) { var prevToken = file.getPrevToken(token); if (token.value === 'else') { if (prevToken.value !== '}') { // Special case for #905, even though it contradicts rule meaning, // it makes more sense that way. return; } if (isPreviousTokenAComment(token, file)) { // Special case for #1421, to handle comments before the else return; } } // Special cases for #885, using while as the keyword contradicts rule meaning // but it is more efficient and reduces complexity of the code in this rule if (token.value === 'while') { var nodes = file.getNodesByFirstToken(token); if (nodes.length === 0) { // "while" that is part of a do will not return nodes as it is not a start token if (prevToken.value !== '}') { // allow "while" that is part of a "do while" with no braces to succeed return; } if (isPreviousTokenAComment(token, file)) { // Special case for #1421, to handle comments before the "while" of a "do while" return; } } else { // it is a "while" statement that is not part of a "do while" // , allow it to succeed even though it contradicts rule meaning return; } } errors.assert.sameLine({ token: prevToken, nextToken: token }); }); } |
| Function (anonymous_392) | |
|---|---|
| ✓ Was called | file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) {··· var prevToken = file.getPrevToken(token); if (token.value === 'else') { if (prevToken.value !== '}') { // Special case for #905, even though it contradicts rule meaning, // it makes more sense that way. return; } if (isPreviousTokenAComment(token, file)) { // Special case for #1421, to handle comments before the else return; } } // Special cases for #885, using while as the keyword contradicts rule meaning // but it is more efficient and reduces complexity of the code in this rule if (token.value === 'while') { var nodes = file.getNodesByFirstToken(token); if (nodes.length === 0) { // "while" that is part of a do will not return nodes as it is not a start token if (prevToken.value !== '}') { // allow "while" that is part of a "do while" with no braces to succeed return; } if (isPreviousTokenAComment(token, file)) { // Special case for #1421, to handle comments before the "while" of a "do while" return; } } else { // it is a "while" statement that is not part of a "do while" // , allow it to succeed even though it contradicts rule meaning return; } } errors.assert.sameLine({ token: prevToken, nextToken: token }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (token.value === 'else') {··· if (prevToken.value !== '}') { // Special case for #905, even though it contradicts rule meaning, // it makes more sense that way. return; } if (isPreviousTokenAComment(token, file)) { // Special case for #1421, to handle comments before the else return; } } |
| ✓ Negative was executed (else) | }··· // Special cases for #885, using while as the keyword contradicts rule meaning |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (prevToken.value !== '}') {··· // Special case for #905, even though it contradicts rule meaning, // it makes more sense that way. return; } |
| ✓ Negative was executed (else) | }··· if (isPreviousTokenAComment(token, file)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isPreviousTokenAComment(token, file)) {··· // Special case for #1421, to handle comments before the else return; } |
| ✓ Negative was executed (else) | }··· } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (token.value === 'while') {··· var nodes = file.getNodesByFirstToken(token); if (nodes.length === 0) { // "while" that is part of a do will not return nodes as it is not a start token if (prevToken.value !== '}') { // allow "while" that is part of a "do while" with no braces to succeed return; } if (isPreviousTokenAComment(token, file)) { // Special case for #1421, to handle comments before the "while" of a "do while" return; } } else { // it is a "while" statement that is not part of a "do while" // , allow it to succeed even though it contradicts rule meaning return; } } |
| ✓ Negative was executed (else) | }··· errors.assert.sameLine({ |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (nodes.length === 0) {··· // "while" that is part of a do will not return nodes as it is not a start token if (prevToken.value !== '}') { // allow "while" that is part of a "do while" with no braces to succeed return; } if (isPreviousTokenAComment(token, file)) { // Special case for #1421, to handle comments before the "while" of a "do while" return; } } else { |
| ✓ Negative was executed (else) | } else {··· // it is a "while" statement that is not part of a "do while" // , allow it to succeed even though it contradicts rule meaning return; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (prevToken.value !== '}') {··· // allow "while" that is part of a "do while" with no braces to succeed return; } |
| ✓ Negative was executed (else) | }··· if (isPreviousTokenAComment(token, file)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isPreviousTokenAComment(token, file)) {··· // Special case for #1421, to handle comments before the "while" of a "do while" return; } |
| ✓ Negative was executed (else) | }··· } else { |
| Function (anonymous_393) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_394) | |
|---|---|
| ✓ Was called | configure: function(keywords) {··· assert(Array.isArray(keywords), this.getOptionName() + ' option requires array value'); this._keywords = keywords; }, |
| Function (anonymous_395) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowKeywords'; }, |
| Function (anonymous_396) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) { errors.add( 'Illegal keyword: ' + token.value, token.loc.start ); }); } |
| Function (anonymous_397) | |
|---|---|
| ✓ Was called | file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) {··· errors.add( 'Illegal keyword: ' + token.value, token.loc.start ); }); |
| Function (anonymous_398) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_399) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true || options === 'smart', this.getOptionName() + ' option requires a true value or "smart"' ); this._options = options; }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options === true || options === 'smart', |
| ✓ Was returned | options === true || options === 'smart', |
| Function (anonymous_400) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowMixedSpacesAndTabs'; }, |
| Function (anonymous_401) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var test = this._options === true ? (/ \t|\t [^\*]|\t $/) : (/ \t/); file.getLinesWithCommentsRemoved().forEach(function(line, i) { if (line.match(test)) { errors.add('Mixed spaces and tabs found', i + 1, 0); } }); } |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | (/ \t|\t [^\*]|\t $/) : |
| ✓ Negative was returned (: ...) | (/ \t/); |
| Function (anonymous_402) | |
|---|---|
| ✓ Was called | file.getLinesWithCommentsRemoved().forEach(function(line, i) {··· if (line.match(test)) { errors.add('Mixed spaces and tabs found', i + 1, 0); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (line.match(test)) {··· errors.add('Mixed spaces and tabs found', i + 1, 0); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_403) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_404) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_405) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowMultiLineTernary'; }, |
| Function (anonymous_406) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('ConditionalExpression', function(node) { errors.assert.sameLine({ token: node.test, nextToken: node.consequent, message: 'Illegal new line after test' }); errors.assert.sameLine({ token: node.consequent, nextToken: node.alternate, message: 'Illegal new line after consequent' }); }); } |
| Function (anonymous_407) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('ConditionalExpression', function(node) {··· errors.assert.sameLine({ token: node.test, nextToken: node.consequent, message: 'Illegal new line after test' }); errors.assert.sameLine({ token: node.consequent, nextToken: node.alternate, message: 'Illegal new line after consequent' }); }); |
| Function (anonymous_408) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_409) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_410) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowMultipleLineBreaks'; }, |
| Function (anonymous_411) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· // Iterate over all tokens (including comments) file.getTokens().forEach(function(token) { if (token.type === 'Whitespace') { return; } // If there are no trailing tokens, exit early var nextToken = file.getNextToken(token, {includeComments: true}); if (!nextToken) { return; } errors.assert.linesBetween({ token: token, nextToken: nextToken, atMost: 2 }); }); } |
| Function (anonymous_412) | |
|---|---|
| ✓ Was called | file.getTokens().forEach(function(token) {··· if (token.type === 'Whitespace') { return; } // If there are no trailing tokens, exit early var nextToken = file.getNextToken(token, {includeComments: true}); if (!nextToken) { return; } errors.assert.linesBetween({ token: token, nextToken: nextToken, atMost: 2 }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (token.type === 'Whitespace') {··· return; } |
| ✓ Negative was executed (else) | }··· // If there are no trailing tokens, exit early |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!nextToken) {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.linesBetween({ |
| Function (anonymous_413) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_414) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_415) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowMultipleLineStrings'; }, |
| Function (anonymous_416) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateTokensByType('String', function(token) { if (token.loc.start.line !== token.loc.end.line) { errors.add( 'Multiline strings are disallowed.', token.loc.start.line, token.loc.start.column ); } }); } |
| Function (anonymous_417) | |
|---|---|
| ✓ Was called | file.iterateTokensByType('String', function(token) {··· if (token.loc.start.line !== token.loc.end.line) { errors.add( 'Multiline strings are disallowed.', token.loc.start.line, token.loc.start.column ); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (token.loc.start.line !== token.loc.end.line) {··· errors.add( 'Multiline strings are disallowed.', token.loc.start.line, token.loc.start.column ); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_418) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_419) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true || typeof options === 'object' && options.allowEOLComments === true, this.getOptionName() + ' option requires true value ' + 'or an object with `allowEOLComments` property' ); this.allowEOLComments = options.allowEOLComments; }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | typeof options === 'object' &&··· options.allowEOLComments === true, |
| ✓ Was returned | options === true || |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options.allowEOLComments === true, |
| ✓ Was returned | typeof options === 'object' && |
| Function (anonymous_420) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowMultipleSpaces'; }, |
| Function (anonymous_421) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· // Iterate over all tokens (including comments) var _this = this; file.getTokens().forEach(function(token) { if (token.type === 'Whitespace') { return; } // If there are no trailing tokens, exit early var nextToken = file.getNextToken(token, {includeComments: true}); if (!nextToken) { return; } // If we are allowing EOL comments and the next token is an EOL comment skip it // We don't need to check the current token since EOL comments must be on separate lines from the next one if (_this.allowEOLComments && nextToken.type === 'Line') { return; } // Verify we have at most 1 space between this token and the next (won't fail for different lines) errors.assert.spacesBetween({ token: token, nextToken: nextToken, atMost: 1 }); }); } |
| Function (anonymous_422) | |
|---|---|
| ✓ Was called | file.getTokens().forEach(function(token) {··· if (token.type === 'Whitespace') { return; } // If there are no trailing tokens, exit early var nextToken = file.getNextToken(token, {includeComments: true}); if (!nextToken) { return; } // If we are allowing EOL comments and the next token is an EOL comment skip it // We don't need to check the current token since EOL comments must be on separate lines from the next one if (_this.allowEOLComments && nextToken.type === 'Line') { return; } // Verify we have at most 1 space between this token and the next (won't fail for different lines) errors.assert.spacesBetween({ token: token, nextToken: nextToken, atMost: 1 }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (token.type === 'Whitespace') {··· return; } |
| ✓ Negative was executed (else) | }··· // If there are no trailing tokens, exit early |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!nextToken) {··· return; } |
| ✓ Negative was executed (else) | }··· // If we are allowing EOL comments and the next token is an EOL comment skip it |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (_this.allowEOLComments && nextToken.type === 'Line') {··· return; } |
| ✓ Negative was executed (else) | }··· // Verify we have at most 1 space between this token and the next (won't fail for different lines) |
| Branch LogicalExpression | |
| ✓ Was returned | if (_this.allowEOLComments && nextToken.type === 'Line') { |
| ✓ Was returned | if (_this.allowEOLComments && nextToken.type === 'Line') { |
| Function (anonymous_423) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_424) | |
|---|---|
| ✓ Was called | configure: function(options) {··· // support for legacy options if (typeof options !== 'object') { assert( options === true || options === 'strict' || options === 'exceptUndefined', this.getOptionName() + ' option requires a true value, "strict", "exceptUndefined", or an object' ); var _options = { strict: options === 'strict', allExcept: [] }; if (options === 'exceptUndefined') { _options.allExcept.push('undefined'); } return this.configure(_options); } if (Array.isArray(options.allExcept)) { this._exceptUndefined = options.allExcept.indexOf('undefined') > -1; this._exceptRequire = options.allExcept.indexOf('require') > -1; } this._strictMode = options.strict === true; }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof options !== 'object') {··· assert( options === true || options === 'strict' || options === 'exceptUndefined', this.getOptionName() + ' option requires a true value, "strict", "exceptUndefined", or an object' ); var _options = { strict: options === 'strict', allExcept: [] }; if (options === 'exceptUndefined') { _options.allExcept.push('undefined'); } return this.configure(_options); } |
| ✓ Negative was executed (else) | }··· if (Array.isArray(options.allExcept)) { |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options === 'exceptUndefined', |
| ✓ Was returned | options === true ||··· options === 'strict' || |
| Branch LogicalExpression | |
| ✓ Was returned | options === 'strict' || |
| ✓ Was returned | options === true || |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options === 'exceptUndefined') {··· _options.allExcept.push('undefined'); } |
| ✓ Negative was executed (else) | }··· return this.configure(_options); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (Array.isArray(options.allExcept)) {··· this._exceptUndefined = options.allExcept.indexOf('undefined') > -1; this._exceptRequire = options.allExcept.indexOf('require') > -1; } |
| ✓ Negative was executed (else) | }··· this._strictMode = options.strict === true; |
| Function (anonymous_425) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowMultipleVarDecl'; }, |
| Function (anonymous_426) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· function isSourcedFromRequire(node) { // If this node is a CallExpression it has a callee, // check if this is the `require` function if (node.callee && node.callee.name === 'require') { return true; } // If this CallExpression is not a `require` we keep looking for // the `require` method up in the tree if (node.callee && node.callee.object) { return isSourcedFromRequire(node.callee.object); } // If there is no `callee` this might be a MemberExpression, keep // look for the `require` method up in the tree. if (node.object) { return isSourcedFromRequire(node.object); } return false; } var inStrictMode = this._strictMode; var exceptUndefined = this._exceptUndefined; var exceptRequire = this._exceptRequire; file.iterateNodesByType('VariableDeclaration', function(node) { var definedVariables = node.declarations.filter(function(declaration) { return !!declaration.init; }); var hasDefinedVariables = definedVariables.length > 0; var requireStatements = node.declarations.filter(function(declaration) { var init = declaration.init; return init && isSourcedFromRequire(init); }); var allRequireStatements = requireStatements.length === node.declarations.length; var isForStatement = node.parentNode.type === 'ForStatement'; // allow single var declarations if (node.declarations.length === 1) { return; } // allow multiple var declarations in for statement unless we're in strict mode // for (var i = 0, j = myArray.length; i < j; i++) {} if (!inStrictMode && isForStatement) { return; } // allow multiple var declarations with all undefined variables in exceptUndefined mode // var a, b, c if (exceptUndefined && !hasDefinedVariables) { return; } // allow multiple var declaration with all require // var a = require("a"), b = require("b") if (exceptRequire && allRequireStatements) { return; } // allow multiple var declarations only with require && undefined // var a = require("a"), b = require("b"), x, y if (exceptUndefined && exceptRequire && definedVariables.length === requireStatements.length) { return; } errors.add('Multiple var declaration', node.loc.start); }); } |
| Function isSourcedFromRequire | |
|---|---|
| ✓ Was called | function isSourcedFromRequire(node) {··· // If this node is a CallExpression it has a callee, // check if this is the `require` function if (node.callee && node.callee.name === 'require') { return true; } // If this CallExpression is not a `require` we keep looking for // the `require` method up in the tree if (node.callee && node.callee.object) { return isSourcedFromRequire(node.callee.object); } // If there is no `callee` this might be a MemberExpression, keep // look for the `require` method up in the tree. if (node.object) { return isSourcedFromRequire(node.object); } return false; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.callee && node.callee.name === 'require') {··· return true; } |
| ✓ Negative was executed (else) | }··· // If this CallExpression is not a `require` we keep looking for |
| Branch LogicalExpression | |
| ✓ Was returned | if (node.callee && node.callee.name === 'require') { |
| ✓ Was returned | if (node.callee && node.callee.name === 'require') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.callee && node.callee.object) {··· return isSourcedFromRequire(node.callee.object); } |
| ✓ Negative was executed (else) | }··· // If there is no `callee` this might be a MemberExpression, keep |
| Branch LogicalExpression | |
| ✓ Was returned | if (node.callee && node.callee.object) { |
| ✓ Was returned | if (node.callee && node.callee.object) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.object) {··· return isSourcedFromRequire(node.object); } |
| ✓ Negative was executed (else) | }··· return false; |
| Function (anonymous_428) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('VariableDeclaration', function(node) {··· var definedVariables = node.declarations.filter(function(declaration) { return !!declaration.init; }); var hasDefinedVariables = definedVariables.length > 0; var requireStatements = node.declarations.filter(function(declaration) { var init = declaration.init; return init && isSourcedFromRequire(init); }); var allRequireStatements = requireStatements.length === node.declarations.length; var isForStatement = node.parentNode.type === 'ForStatement'; // allow single var declarations if (node.declarations.length === 1) { return; } // allow multiple var declarations in for statement unless we're in strict mode // for (var i = 0, j = myArray.length; i < j; i++) {} if (!inStrictMode && isForStatement) { return; } // allow multiple var declarations with all undefined variables in exceptUndefined mode // var a, b, c if (exceptUndefined && !hasDefinedVariables) { return; } // allow multiple var declaration with all require // var a = require("a"), b = require("b") if (exceptRequire && allRequireStatements) { return; } // allow multiple var declarations only with require && undefined // var a = require("a"), b = require("b"), x, y if (exceptUndefined && exceptRequire && definedVariables.length === requireStatements.length) { return; } errors.add('Multiple var declaration', node.loc.start); }); |
| Function (anonymous_429) | |
|---|---|
| ✓ Was called | var definedVariables = node.declarations.filter(function(declaration) {··· return !!declaration.init; }); |
| Function (anonymous_430) | |
|---|---|
| ✓ Was called | var requireStatements = node.declarations.filter(function(declaration) {··· var init = declaration.init; return init && isSourcedFromRequire(init); }); |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | return init && isSourcedFromRequire(init); |
| ✓ Was returned | return init && isSourcedFromRequire(init); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.declarations.length === 1) {··· return; } |
| ✓ Negative was executed (else) | }··· // allow multiple var declarations in for statement unless we're in strict mode |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!inStrictMode && isForStatement) {··· return; } |
| ✓ Negative was executed (else) | }··· // allow multiple var declarations with all undefined variables in exceptUndefined mode |
| Branch LogicalExpression | |
| ✓ Was returned | if (!inStrictMode && isForStatement) { |
| ✓ Was returned | if (!inStrictMode && isForStatement) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (exceptUndefined && !hasDefinedVariables) {··· return; } |
| ✓ Negative was executed (else) | }··· // allow multiple var declaration with all require |
| Branch LogicalExpression | |
| ✓ Was returned | if (exceptUndefined && !hasDefinedVariables) { |
| ✓ Was returned | if (exceptUndefined && !hasDefinedVariables) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (exceptRequire && allRequireStatements) {··· return; } |
| ✓ Negative was executed (else) | }··· // allow multiple var declarations only with require && undefined |
| Branch LogicalExpression | |
| ✓ Was returned | if (exceptRequire && allRequireStatements) { |
| ✓ Was returned | if (exceptRequire && allRequireStatements) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (exceptUndefined && exceptRequire && definedVariables.length === requireStatements.length) {··· return; } |
| ✓ Negative was executed (else) | }··· errors.add('Multiple var declaration', node.loc.start); |
| Branch LogicalExpression | |
| ✓ Was returned | if (exceptUndefined && exceptRequire && definedVariables.length === requireStatements.length) { |
| ✓ Was returned | if (exceptUndefined && exceptRequire && definedVariables.length === requireStatements.length) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (exceptUndefined && exceptRequire && definedVariables.length === requireStatements.length) { |
| ✓ Was returned | if (exceptUndefined && exceptRequire && definedVariables.length === requireStatements.length) { |
| Function (anonymous_431) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_432) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires true value' ); }, |
| Function (anonymous_433) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowNamedUnassignedFunctions'; }, |
| Function (anonymous_434) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('FunctionExpression', function(node) { // If the function has been named via left hand assignment, skip it // e.g. `var hello = function() {`, `foo.bar = function() {` if (node.parentNode.type.match(/VariableDeclarator|Property|AssignmentExpression/)) { return; } // If the function has not been named, skip it // e.g. `[].forEach(function() {` if (node.id === null) { return; } // Otherwise, complain that it is being named errors.add('Inline functions cannot be named', node.loc.start); }); } |
| Function (anonymous_435) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('FunctionExpression', function(node) {··· // If the function has been named via left hand assignment, skip it // e.g. `var hello = function() {`, `foo.bar = function() {` if (node.parentNode.type.match(/VariableDeclarator|Property|AssignmentExpression/)) { return; } // If the function has not been named, skip it // e.g. `[].forEach(function() {` if (node.id === null) { return; } // Otherwise, complain that it is being named errors.add('Inline functions cannot be named', node.loc.start); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.parentNode.type.match(/VariableDeclarator|Property|AssignmentExpression/)) {··· return; } |
| ✓ Negative was executed (else) | }··· // If the function has not been named, skip it |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.id === null) {··· return; } |
| ✓ Negative was executed (else) | }··· // Otherwise, complain that it is being named |
| Function (anonymous_436) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_437) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true || (typeof options.maxLevel === 'number' && options.maxLevel > 0), this.getOptionName() + ' option requires a true value or an object with "maxLevel" property' ); this._maxLevel = 0; if (options.maxLevel) { this._maxLevel = options.maxLevel; } }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options === true || (typeof options.maxLevel === 'number' && options.maxLevel > 0), |
| ✓ Was returned | options === true || (typeof options.maxLevel === 'number' && options.maxLevel > 0), |
| Branch LogicalExpression | |
| ✓ Was returned | options === true || (typeof options.maxLevel === 'number' && options.maxLevel > 0), |
| ✗ Was not returned | options === true || (typeof options.maxLevel === 'number' && options.maxLevel > 0), |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options.maxLevel) {··· this._maxLevel = options.maxLevel; } |
| ✓ Negative was executed (else) | }··· }, |
| Function (anonymous_438) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowNestedTernaries'; }, |
| Function (anonymous_439) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var maxLevel = this._maxLevel; file.iterateNodesByType('ConditionalExpression', function(node) { var level = 0; var getLevel = function(currentNode) { if (currentNode.parentNode && currentNode.parentNode.type === 'ConditionalExpression') { level += 1; if (level > maxLevel) { errors.add('Illegal nested ternary', node.loc.start.line, node.loc.start.column); return; } getLevel(currentNode.parentNode); } }; getLevel(node); }); } |
| Function (anonymous_440) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('ConditionalExpression', function(node) {··· var level = 0; var getLevel = function(currentNode) { if (currentNode.parentNode && currentNode.parentNode.type === 'ConditionalExpression') { level += 1; if (level > maxLevel) { errors.add('Illegal nested ternary', node.loc.start.line, node.loc.start.column); return; } getLevel(currentNode.parentNode); } }; getLevel(node); }); |
| Function (anonymous_441) | |
|---|---|
| ✓ Was called | var getLevel = function(currentNode) {··· if (currentNode.parentNode && currentNode.parentNode.type === 'ConditionalExpression') { level += 1; if (level > maxLevel) { errors.add('Illegal nested ternary', node.loc.start.line, node.loc.start.column); return; } getLevel(currentNode.parentNode); } }; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (currentNode.parentNode && currentNode.parentNode.type === 'ConditionalExpression') {··· level += 1; if (level > maxLevel) { errors.add('Illegal nested ternary', node.loc.start.line, node.loc.start.column); return; } getLevel(currentNode.parentNode); } |
| ✓ Negative was executed (else) | }··· }; |
| Branch LogicalExpression | |
| ✓ Was returned | if (currentNode.parentNode && currentNode.parentNode.type === 'ConditionalExpression') { |
| ✗ Was not returned | if (currentNode.parentNode && currentNode.parentNode.type === 'ConditionalExpression') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (level > maxLevel) {··· errors.add('Illegal nested ternary', node.loc.start.line, node.loc.start.column); return; } |
| ✓ Negative was executed (else) | }··· getLevel(currentNode.parentNode); |
| Function (anonymous_442) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_443) | |
|---|---|
| ✓ Was called | configure: function(options) {··· var settingValue; this._hasMultiLineEx = false; if (options.constructor === Object) { settingValue = options.value; if (options.allExcept) { assert( Array.isArray(options.allExcept) && options.allExcept.length === 1 && options.allExcept[0] === 'multiLine', 'allExcept option must be an array whose values can be only `multiLine`' ); this._hasMultiLineEx = true; } } else { settingValue = options; } assert( Array.isArray(settingValue) && settingValue.length || settingValue === true, 'disallowNewlineBeforeBlockStatements option requires non-empty array value or true value' ); this._setting = settingValue; }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options.constructor === Object) {··· settingValue = options.value; if (options.allExcept) { assert( Array.isArray(options.allExcept) && options.allExcept.length === 1 && options.allExcept[0] === 'multiLine', 'allExcept option must be an array whose values can be only `multiLine`' ); this._hasMultiLineEx = true; } } else { |
| ✓ Negative was executed (else) | } else {··· settingValue = options; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options.allExcept) {··· assert( Array.isArray(options.allExcept) && options.allExcept.length === 1 && options.allExcept[0] === 'multiLine', 'allExcept option must be an array whose values can be only `multiLine`' ); this._hasMultiLineEx = true; } |
| ✗ Negative was not executed (else) | }··· } else { |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options.allExcept[0] === 'multiLine', |
| ✗ Was not returned | Array.isArray(options.allExcept) && options.allExcept.length === 1 && |
| Branch LogicalExpression | |
| ✓ Was returned | Array.isArray(options.allExcept) && options.allExcept.length === 1 && |
| ✗ Was not returned | Array.isArray(options.allExcept) && options.allExcept.length === 1 && |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | Array.isArray(settingValue) && settingValue.length || settingValue === true, |
| ✓ Was returned | Array.isArray(settingValue) && settingValue.length || settingValue === true, |
| Branch LogicalExpression | |
| ✓ Was returned | Array.isArray(settingValue) && settingValue.length || settingValue === true, |
| ✓ Was returned | Array.isArray(settingValue) && settingValue.length || settingValue === true, |
| Function (anonymous_444) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowNewlineBeforeBlockStatements'; }, |
| Function (anonymous_445) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var setting = this._setting; var hasMultiLineEx = this._hasMultiLineEx; function assertSameLine(token, nextToken) { errors.assert.sameLine({ token: token, nextToken: nextToken, message: 'Newline before curly brace for block statement is disallowed' }); } function assertDifferentLine(token, nextToken) { errors.assert.differentLine({ token: token, nextToken: nextToken, message: 'Newline before curly brace for block statement is required' }); } file.iterateNodesByType(['BlockStatement', 'ClassBody'], function(node) { if (isBareBlock(node)) { return; } if (setting === true || setting.indexOf(getBlockType(node)) !== -1) { var openingBrace = file.getFirstNodeToken(node); var prevToken = file.getPrevToken(openingBrace); if (hasMultiLineEx !== true) { assertSameLine(prevToken, openingBrace); return; } // Check if the 'conditions' span on multiple lines. // The simplest way is to check if the round braces are on different lines. // // For example: // // same line // for (var i = 0; i < length; i++) { // } // // // different lines: // for (var i = 0; // i < length; // i++) // { // } var parentNode = node.parentNode; var parentNextToken = file.getFirstNodeToken(parentNode); var openingRoundBrace = file.findNextToken(parentNextToken, 'Punctuator', '('); var closingRoundBrace = file.findPrevToken(openingBrace, 'Punctuator', ')'); // Not always the conditions are there: to check look for the presence of round braces. // For example: // try { // } ... if (openingRoundBrace && closingRoundBrace && openingRoundBrace.loc.start.line !== closingRoundBrace.loc.end.line) { assertDifferentLine(prevToken, openingBrace); } else { assertSameLine(prevToken, openingBrace); } } }); if (setting === true || setting.indexOf('switch') !== -1) { file.iterateNodesByType(['SwitchStatement'], function(node) { var openingBrace = file.findNextToken(file.getLastNodeToken(node.discriminant), 'Punctuator', '{'); var prevToken = file.getPrevToken(openingBrace); if (hasMultiLineEx !== true) { assertSameLine(prevToken, openingBrace); return; } var openingRoundBrace = file.findNextToken(file.getFirstNodeToken(node), 'Punctuator', '('); var closingRoundBrace = file.findPrevToken(openingBrace, 'Punctuator', ')'); if (openingRoundBrace.loc.start.line !== closingRoundBrace.loc.end.line) { assertDifferentLine(prevToken, openingBrace); } else { assertSameLine(prevToken, openingBrace); } }); } } |
| Function assertSameLine | |
|---|---|
| ✓ Was called | function assertSameLine(token, nextToken) {··· errors.assert.sameLine({ token: token, nextToken: nextToken, message: 'Newline before curly brace for block statement is disallowed' }); } |
| Function assertDifferentLine | |
|---|---|
| ✓ Was called | function assertDifferentLine(token, nextToken) {··· errors.assert.differentLine({ token: token, nextToken: nextToken, message: 'Newline before curly brace for block statement is required' }); } |
| Function (anonymous_448) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['BlockStatement', 'ClassBody'], function(node) {··· if (isBareBlock(node)) { return; } if (setting === true || setting.indexOf(getBlockType(node)) !== -1) { var openingBrace = file.getFirstNodeToken(node); var prevToken = file.getPrevToken(openingBrace); if (hasMultiLineEx !== true) { assertSameLine(prevToken, openingBrace); return; } // Check if the 'conditions' span on multiple lines. // The simplest way is to check if the round braces are on different lines. // // For example: // // same line // for (var i = 0; i < length; i++) { // } // // // different lines: // for (var i = 0; // i < length; // i++) // { // } var parentNode = node.parentNode; var parentNextToken = file.getFirstNodeToken(parentNode); var openingRoundBrace = file.findNextToken(parentNextToken, 'Punctuator', '('); var closingRoundBrace = file.findPrevToken(openingBrace, 'Punctuator', ')'); // Not always the conditions are there: to check look for the presence of round braces. // For example: // try { // } ... if (openingRoundBrace && closingRoundBrace && openingRoundBrace.loc.start.line !== closingRoundBrace.loc.end.line) { assertDifferentLine(prevToken, openingBrace); } else { assertSameLine(prevToken, openingBrace); } } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isBareBlock(node)) {··· return; } |
| ✓ Negative was executed (else) | }··· if (setting === true || setting.indexOf(getBlockType(node)) !== -1) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (setting === true || setting.indexOf(getBlockType(node)) !== -1) {··· var openingBrace = file.getFirstNodeToken(node); var prevToken = file.getPrevToken(openingBrace); if (hasMultiLineEx !== true) { assertSameLine(prevToken, openingBrace); return; } // Check if the 'conditions' span on multiple lines. // The simplest way is to check if the round braces are on different lines. // // For example: // // same line // for (var i = 0; i < length; i++) { // } // // // different lines: // for (var i = 0; // i < length; // i++) // { // } var parentNode = node.parentNode; var parentNextToken = file.getFirstNodeToken(parentNode); var openingRoundBrace = file.findNextToken(parentNextToken, 'Punctuator', '('); var closingRoundBrace = file.findPrevToken(openingBrace, 'Punctuator', ')'); // Not always the conditions are there: to check look for the presence of round braces. // For example: // try { // } ... if (openingRoundBrace && closingRoundBrace && openingRoundBrace.loc.start.line !== closingRoundBrace.loc.end.line) { assertDifferentLine(prevToken, openingBrace); } else { assertSameLine(prevToken, openingBrace); } } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | if (setting === true || setting.indexOf(getBlockType(node)) !== -1) { |
| ✓ Was returned | if (setting === true || setting.indexOf(getBlockType(node)) !== -1) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (hasMultiLineEx !== true) {··· assertSameLine(prevToken, openingBrace); return; } |
| ✓ Negative was executed (else) | }··· // Check if the 'conditions' span on multiple lines. |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | openingRoundBrace.loc.start.line !== closingRoundBrace.loc.end.line) {··· assertDifferentLine(prevToken, openingBrace); } else { |
| ✓ Negative was executed (else) | } else {··· assertSameLine(prevToken, openingBrace); } |
| Branch LogicalExpression | |
| ✓ Was returned | openingRoundBrace.loc.start.line !== closingRoundBrace.loc.end.line) { |
| ✓ Was returned | if (openingRoundBrace && closingRoundBrace && |
| Branch LogicalExpression | |
| ✓ Was returned | if (openingRoundBrace && closingRoundBrace && |
| ✗ Was not returned | if (openingRoundBrace && closingRoundBrace && |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (setting === true || setting.indexOf('switch') !== -1) {··· file.iterateNodesByType(['SwitchStatement'], function(node) { var openingBrace = file.findNextToken(file.getLastNodeToken(node.discriminant), 'Punctuator', '{'); var prevToken = file.getPrevToken(openingBrace); if (hasMultiLineEx !== true) { assertSameLine(prevToken, openingBrace); return; } var openingRoundBrace = file.findNextToken(file.getFirstNodeToken(node), 'Punctuator', '('); var closingRoundBrace = file.findPrevToken(openingBrace, 'Punctuator', ')'); if (openingRoundBrace.loc.start.line !== closingRoundBrace.loc.end.line) { assertDifferentLine(prevToken, openingBrace); } else { assertSameLine(prevToken, openingBrace); } }); } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | if (setting === true || setting.indexOf('switch') !== -1) { |
| ✓ Was returned | if (setting === true || setting.indexOf('switch') !== -1) { |
| Function (anonymous_449) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['SwitchStatement'], function(node) {··· var openingBrace = file.findNextToken(file.getLastNodeToken(node.discriminant), 'Punctuator', '{'); var prevToken = file.getPrevToken(openingBrace); if (hasMultiLineEx !== true) { assertSameLine(prevToken, openingBrace); return; } var openingRoundBrace = file.findNextToken(file.getFirstNodeToken(node), 'Punctuator', '('); var closingRoundBrace = file.findPrevToken(openingBrace, 'Punctuator', ')'); if (openingRoundBrace.loc.start.line !== closingRoundBrace.loc.end.line) { assertDifferentLine(prevToken, openingBrace); } else { assertSameLine(prevToken, openingBrace); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (hasMultiLineEx !== true) {··· assertSameLine(prevToken, openingBrace); return; } |
| ✓ Negative was executed (else) | }··· var openingRoundBrace = file.findNextToken(file.getFirstNodeToken(node), 'Punctuator', '('); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (openingRoundBrace.loc.start.line !== closingRoundBrace.loc.end.line) {··· assertDifferentLine(prevToken, openingBrace); } else { |
| ✓ Negative was executed (else) | } else {··· assertSameLine(prevToken, openingBrace); } |
| Function isBareBlock | |
|---|---|
| ✓ Was called | function isBareBlock(node) {··· var parentNode = node.parentNode; return parentNode && parentNode.type === 'BlockStatement' || parentNode.type === 'Program' || parentNode.body && parentNode.body.type === 'BlockStatement' && Array.isArray(parentNode.body); } |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | parentNode.body && parentNode.body.type === 'BlockStatement' && Array.isArray(parentNode.body); |
| ✓ Was returned | return parentNode &&··· parentNode.type === 'BlockStatement' || parentNode.type === 'Program' || |
| Branch LogicalExpression | |
| ✓ Was returned | parentNode.type === 'Program' || |
| ✓ Was returned | return parentNode &&··· parentNode.type === 'BlockStatement' || |
| Branch LogicalExpression | |
| ✓ Was returned | parentNode.type === 'BlockStatement' || |
| ✗ Was not returned | return parentNode && |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | parentNode.body && parentNode.body.type === 'BlockStatement' && Array.isArray(parentNode.body); |
| ✓ Was returned | parentNode.body && parentNode.body.type === 'BlockStatement' && Array.isArray(parentNode.body); |
| Branch LogicalExpression | |
| ✓ Was returned | parentNode.body && parentNode.body.type === 'BlockStatement' && Array.isArray(parentNode.body); |
| ✓ Was returned | parentNode.body && parentNode.body.type === 'BlockStatement' && Array.isArray(parentNode.body); |
| Function getBlockType | |
|---|---|
| ✓ Was called | function getBlockType(node) {··· var parentNode = node.parentNode; switch (parentNode.type) { case 'IfStatement': return (parentNode.alternate === node) ? 'else' : 'if'; case 'FunctionDeclaration': case 'FunctionExpression': case 'ArrowFunctionExpression': return 'function'; case 'ForStatement': case 'ForInStatement': case 'ForOfStatement': return 'for'; case 'WhileStatement': return 'while'; case 'DoWhileStatement': return 'do'; case 'TryStatement': return (parentNode.finalizer === node) ? 'finally' : 'try'; case 'CatchClause': return 'catch'; case 'ClassDeclaration': return 'class'; } } |
| Branch SwitchStatement | |
|---|---|
| ✓ Was evaluated | case 'IfStatement':··· return (parentNode.alternate === node) ? 'else' : 'if'; |
| ✓ Was evaluated | case 'FunctionDeclaration': |
| ✓ Was evaluated | case 'FunctionExpression': |
| ✓ Was evaluated | case 'ArrowFunctionExpression':··· return 'function'; |
| ✓ Was evaluated | case 'ForStatement': |
| ✓ Was evaluated | case 'ForInStatement': |
| ✓ Was evaluated | case 'ForOfStatement':··· return 'for'; |
| ✓ Was evaluated | case 'WhileStatement':··· return 'while'; |
| ✓ Was evaluated | case 'DoWhileStatement':··· return 'do'; |
| ✓ Was evaluated | case 'TryStatement':··· return (parentNode.finalizer === node) ? 'finally' : 'try'; |
| ✓ Was evaluated | case 'CatchClause':··· return 'catch'; |
| ✓ Was evaluated | case 'ClassDeclaration':··· return 'class'; |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | return (parentNode.alternate === node) ? 'else' : 'if'; |
| ✓ Negative was returned (: ...) | return (parentNode.alternate === node) ? 'else' : 'if'; |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | return (parentNode.finalizer === node) ? 'finally' : 'try'; |
| ✓ Negative was returned (: ...) | return (parentNode.finalizer === node) ? 'finally' : 'try'; |
| Function (anonymous_452) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_453) | |
|---|---|
| ✓ Was called | configure: function(nodeTypes) {··· assert( Array.isArray(nodeTypes), 'disallowNodeTypes option requires an array' ); this._nodeTypes = nodeTypes; }, |
| Function (anonymous_454) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowNodeTypes'; }, |
| Function (anonymous_455) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var disallowedNodeTypes = this._nodeTypes; file.iterateNodesByType(disallowedNodeTypes, function(node) { errors.add('Illegal use of disallowed node type: ' + node.type, node.loc.start); }); } |
| Function (anonymous_456) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(disallowedNodeTypes, function(node) {··· errors.add('Illegal use of disallowed node type: ' + node.type, node.loc.start); }); |
| Function (anonymous_457) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_458) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_459) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowNotOperatorsInConditionals'; }, |
| Function (anonymous_460) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· function hasNotOperator(test) { return test.type === 'UnaryExpression' && test.operator === '!'; } function hasNotEqualOperator(test) { return test.type === 'BinaryExpression' && test.operator === '!='; } function hasStrictNotEqualOperator(test) { return test.type === 'BinaryExpression' && test.operator === '!=='; } file.iterateNodesByType(['IfStatement', 'ConditionalExpression'], function(node) { var alternate = node.alternate; // check if the if statement has an else block if (node.type === 'IfStatement' && (!alternate || alternate.type !== 'BlockStatement')) { return; } var test = node.test; if (hasNotOperator(test)) { errors.add('Illegal use of not operator in if statement', test.loc.start); } if (hasNotEqualOperator(test)) { errors.add('Illegal use of not equal operator in if statement', test.loc.end); } if (hasStrictNotEqualOperator(test)) { errors.add('Illegal use of strict not equal operator in if statement', test.loc.end); } }); } |
| Function hasNotOperator | |
|---|---|
| ✓ Was called | function hasNotOperator(test) {··· return test.type === 'UnaryExpression' && test.operator === '!'; } |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | return test.type === 'UnaryExpression' && test.operator === '!'; |
| ✓ Was returned | return test.type === 'UnaryExpression' && test.operator === '!'; |
| Function hasNotEqualOperator | |
|---|---|
| ✓ Was called | function hasNotEqualOperator(test) {··· return test.type === 'BinaryExpression' && test.operator === '!='; } |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | return test.type === 'BinaryExpression' && test.operator === '!='; |
| ✓ Was returned | return test.type === 'BinaryExpression' && test.operator === '!='; |
| Function hasStrictNotEqualOperator | |
|---|---|
| ✓ Was called | function hasStrictNotEqualOperator(test) {··· return test.type === 'BinaryExpression' && test.operator === '!=='; } |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | return test.type === 'BinaryExpression' && test.operator === '!=='; |
| ✓ Was returned | return test.type === 'BinaryExpression' && test.operator === '!=='; |
| Function (anonymous_464) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['IfStatement', 'ConditionalExpression'], function(node) {··· var alternate = node.alternate; // check if the if statement has an else block if (node.type === 'IfStatement' && (!alternate || alternate.type !== 'BlockStatement')) { return; } var test = node.test; if (hasNotOperator(test)) { errors.add('Illegal use of not operator in if statement', test.loc.start); } if (hasNotEqualOperator(test)) { errors.add('Illegal use of not equal operator in if statement', test.loc.end); } if (hasStrictNotEqualOperator(test)) { errors.add('Illegal use of strict not equal operator in if statement', test.loc.end); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.type === 'IfStatement' && (!alternate || alternate.type !== 'BlockStatement')) {··· return; } |
| ✓ Negative was executed (else) | }··· var test = node.test; |
| Branch LogicalExpression | |
| ✓ Was returned | if (node.type === 'IfStatement' && (!alternate || alternate.type !== 'BlockStatement')) { |
| ✓ Was returned | if (node.type === 'IfStatement' && (!alternate || alternate.type !== 'BlockStatement')) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (node.type === 'IfStatement' && (!alternate || alternate.type !== 'BlockStatement')) { |
| ✓ Was returned | if (node.type === 'IfStatement' && (!alternate || alternate.type !== 'BlockStatement')) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (hasNotOperator(test)) {··· errors.add('Illegal use of not operator in if statement', test.loc.start); } |
| ✓ Negative was executed (else) | }··· if (hasNotEqualOperator(test)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (hasNotEqualOperator(test)) {··· errors.add('Illegal use of not equal operator in if statement', test.loc.end); } |
| ✓ Negative was executed (else) | }··· if (hasStrictNotEqualOperator(test)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (hasStrictNotEqualOperator(test)) {··· errors.add('Illegal use of strict not equal operator in if statement', test.loc.end); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_465) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_466) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_467) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowObjectKeysOnNewLine'; }, |
| Function (anonymous_468) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('ObjectExpression', function(node) { for (var i = 1; i < node.properties.length; i++) { var lastValueToken = file.getLastNodeToken(node.properties[i - 1].value); var comma = file.findNextToken(lastValueToken, 'Punctuator', ','); var firstKeyToken = file.getFirstNodeToken(node.properties[i].key); errors.assert.sameLine({ token: comma, nextToken: firstKeyToken, message: 'Object keys must go on a new line' }); } }); } |
| Function (anonymous_469) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('ObjectExpression', function(node) {··· for (var i = 1; i < node.properties.length; i++) { var lastValueToken = file.getLastNodeToken(node.properties[i - 1].value); var comma = file.findNextToken(lastValueToken, 'Punctuator', ','); var firstKeyToken = file.getFirstNodeToken(node.properties[i].key); errors.assert.sameLine({ token: comma, nextToken: firstKeyToken, message: 'Object keys must go on a new line' }); } }); |
| Function (anonymous_470) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_471) | |
|---|---|
| ✓ Was called | configure: function(operators) {··· assert(Array.isArray(operators) || operators === true, this.getOptionName() + ' option requires array or true value'); if (operators === true) { operators = defaultOperators; } this._operators = operators; }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | assert(Array.isArray(operators) || operators === true, |
| ✓ Was returned | assert(Array.isArray(operators) || operators === true, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (operators === true) {··· operators = defaultOperators; } |
| ✓ Negative was executed (else) | }··· this._operators = operators; |
| Function (anonymous_472) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowOperatorBeforeLineBreak'; }, |
| Function (anonymous_473) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateTokensByTypeAndValue('Punctuator', this._operators, function(token) { errors.assert.sameLine({ token: token, nextToken: file.getNextToken(token), message: 'Operator needs to either be on the same line or after a line break.' }); }); } |
| Function (anonymous_474) | |
|---|---|
| ✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', this._operators, function(token) {··· errors.assert.sameLine({ token: token, nextToken: file.getNextToken(token), message: 'Operator needs to either be on the same line or after a line break.' }); }); |
| Function (anonymous_475) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_476) | |
|---|---|
| ✓ Was called | configure: function(value) {··· assert( value === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_477) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowPaddingNewLinesAfterBlocks'; }, |
| Function (anonymous_478) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('BlockStatement', function(node) { var endToken = file.getLastNodeToken(node); var nextToken = file.getNextToken(endToken); while (nextToken.type !== 'EOF') { if (endToken.loc.end.line === nextToken.loc.start.line) { endToken = nextToken; nextToken = file.getNextToken(nextToken); continue; } errors.assert.linesBetween({ token: endToken, nextToken: nextToken, atMost: 1, message: 'Extra newline after closing curly brace' }); return; } }); } |
| Function (anonymous_479) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('BlockStatement', function(node) {··· var endToken = file.getLastNodeToken(node); var nextToken = file.getNextToken(endToken); while (nextToken.type !== 'EOF') { if (endToken.loc.end.line === nextToken.loc.start.line) { endToken = nextToken; nextToken = file.getNextToken(nextToken); continue; } errors.assert.linesBetween({ token: endToken, nextToken: nextToken, atMost: 1, message: 'Extra newline after closing curly brace' }); return; } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (endToken.loc.end.line === nextToken.loc.start.line) {··· endToken = nextToken; nextToken = file.getNextToken(nextToken); continue; } |
| ✓ Negative was executed (else) | }··· errors.assert.linesBetween({ |
| Function (anonymous_480) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_481) | |
|---|---|
| ✓ Was called | configure: function(disallowPaddingNewLinesAfterUseStrict) {··· assert( disallowPaddingNewLinesAfterUseStrict === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_482) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowPaddingNewLinesAfterUseStrict'; }, |
| Function (anonymous_483) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('ExpressionStatement', function(node) { var expression = node.expression; if (expression.type !== 'Literal' || expression.value !== 'use strict') { return; } var endOfNode = file.getLastNodeToken(node); var nextToken = file.getNextToken(endOfNode, { includeComments: true }); errors.assert.linesBetween({ atMost: 1, token: endOfNode, nextToken: nextToken }); }); } |
| Function (anonymous_484) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('ExpressionStatement', function(node) {··· var expression = node.expression; if (expression.type !== 'Literal' || expression.value !== 'use strict') { return; } var endOfNode = file.getLastNodeToken(node); var nextToken = file.getNextToken(endOfNode, { includeComments: true }); errors.assert.linesBetween({ atMost: 1, token: endOfNode, nextToken: nextToken }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (expression.type !== 'Literal' || expression.value !== 'use strict') {··· return; } |
| ✓ Negative was executed (else) | }··· var endOfNode = file.getLastNodeToken(node); |
| Branch LogicalExpression | |
| ✓ Was returned | if (expression.type !== 'Literal' || expression.value !== 'use strict') { |
| ✓ Was returned | if (expression.type !== 'Literal' || expression.value !== 'use strict') { |
| Function (anonymous_485) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_486) | |
|---|---|
| ✓ Was called | configure: function(value) {··· assert( value === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_487) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowPaddingNewLinesBeforeExport'; }, |
| Function (anonymous_488) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('AssignmentExpression', function(node) { var left = node.left; if (!( left.object && left.object.name === 'module' && left.property && left.property.name === 'exports')) { return; } var firstToken = file.getFirstNodeToken(node); var prevToken = file.getPrevToken(firstToken, {includeComments: true}); errors.assert.linesBetween({ atMost: 1, token: prevToken, nextToken: firstToken, message: 'Unexpected extra newline before export' }); }); } |
| Function (anonymous_489) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('AssignmentExpression', function(node) {··· var left = node.left; if (!( left.object && left.object.name === 'module' && left.property && left.property.name === 'exports')) { return; } var firstToken = file.getFirstNodeToken(node); var prevToken = file.getPrevToken(firstToken, {includeComments: true}); errors.assert.linesBetween({ atMost: 1, token: prevToken, nextToken: firstToken, message: 'Unexpected extra newline before export' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | left.property.name === 'exports')) {··· return; } |
| ✓ Negative was executed (else) | }··· var firstToken = file.getFirstNodeToken(node); |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | left.property.name === 'exports')) { |
| ✓ Was returned | left.object &&··· left.object.name === 'module' && left.property && |
| Branch LogicalExpression | |
| ✓ Was returned | left.property && |
| ✓ Was returned | left.object &&··· left.object.name === 'module' && |
| Branch LogicalExpression | |
| ✓ Was returned | left.object.name === 'module' && |
| ✓ Was returned | left.object && |
| Function (anonymous_490) | |
|---|---|
| ✓ Was called | module.exports = function() { }; |
| Function (anonymous_491) | |
|---|---|
| ✓ Was called | configure: function(keywords) {··· assert(Array.isArray(keywords) || keywords === true, this.getOptionName() + ' option requires array or true value'); if (keywords === true) { keywords = defaultKeywords; } this._keywords = keywords; }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | assert(Array.isArray(keywords) || keywords === true, |
| ✓ Was returned | assert(Array.isArray(keywords) || keywords === true, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (keywords === true) {··· keywords = defaultKeywords; } |
| ✓ Negative was executed (else) | }··· this._keywords = keywords; |
| Function (anonymous_492) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowPaddingNewlinesBeforeKeywords'; }, |
| Function (anonymous_493) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) { errors.assert.linesBetween({ token: file.getPrevToken(token), nextToken: token, atMost: 1, message: 'Keyword `' + token.value + '` should not have an empty line above it' }); }); } |
| Function (anonymous_494) | |
|---|---|
| ✓ Was called | file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) {··· errors.assert.linesBetween({ token: file.getPrevToken(token), nextToken: token, atMost: 1, message: 'Keyword `' + token.value + '` should not have an empty line above it' }); }); |
| Function (anonymous_495) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_496) | |
|---|---|
| ✓ Was called | configure: function(value) {··· assert( value === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_497) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowPaddingNewLinesBeforeLineComments'; }, |
| Function (anonymous_498) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateTokensByType('Line', function(comment) { if (comment.loc.start.line === 1) { return; } errors.assert.linesBetween({ token: file.getPrevToken(comment, {includeComments: true}), nextToken: comment, atMost: 1, message: 'Line comments must not be preceded with a blank line' }); }); } |
| Function (anonymous_499) | |
|---|---|
| ✓ Was called | file.iterateTokensByType('Line', function(comment) {··· if (comment.loc.start.line === 1) { return; } errors.assert.linesBetween({ token: file.getPrevToken(comment, {includeComments: true}), nextToken: comment, atMost: 1, message: 'Line comments must not be preceded with a blank line' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (comment.loc.start.line === 1) {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.linesBetween({ |
| Function (anonymous_500) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_501) | |
|---|---|
| ✓ Was called | configure: function(options) {··· var optionName = this.getOptionName(); this._checkOpen = true; this._checkClose = true; if (typeof options === 'object') { assert(options.allExcept || options.open || options.close, optionName + 'option requires either "open", "close", "allExcept"'); if (options.allExcept) { assert(Array.isArray(options.allExcept), optionName + ' option requires "allExcept" to be an array'); assert(options.allExcept.length > 0, optionName + ' option requires "allExcept" to have at least one ' + 'item or be set to `true`'); this._exceptConditionals = options.allExcept.indexOf('conditionals') > -1; this._exceptFunctions = options.allExcept.indexOf('functions') > -1; } if (options.open || options.close) { assert(typeof options.open === 'boolean' && typeof options.close === 'boolean', this.getOptionName() + ' option requires the "open" and "close" ' + 'properties to be booleans'); this._checkOpen = options.open; this._checkClose = options.close; } } else { assert(options === true, this.getOptionName() + ' option requires either a true value, or an object'); } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof options === 'object') {··· assert(options.allExcept || options.open || options.close, optionName + 'option requires either "open", "close", "allExcept"'); if (options.allExcept) { assert(Array.isArray(options.allExcept), optionName + ' option requires "allExcept" to be an array'); assert(options.allExcept.length > 0, optionName + ' option requires "allExcept" to have at least one ' + 'item or be set to `true`'); this._exceptConditionals = options.allExcept.indexOf('conditionals') > -1; this._exceptFunctions = options.allExcept.indexOf('functions') > -1; } if (options.open || options.close) { assert(typeof options.open === 'boolean' && typeof options.close === 'boolean', this.getOptionName() + ' option requires the "open" and "close" ' + 'properties to be booleans'); this._checkOpen = options.open; this._checkClose = options.close; } } else { |
| ✓ Negative was executed (else) | } else {··· assert(options === true, this.getOptionName() + ' option requires either a true value, or an object'); } |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | assert(options.allExcept || options.open || options.close, |
| ✓ Was returned | assert(options.allExcept || options.open || options.close, |
| Branch LogicalExpression | |
| ✓ Was returned | assert(options.allExcept || options.open || options.close, |
| ✓ Was returned | assert(options.allExcept || options.open || options.close, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options.allExcept) {··· assert(Array.isArray(options.allExcept), optionName + ' option requires "allExcept" to be an array'); assert(options.allExcept.length > 0, optionName + ' option requires "allExcept" to have at least one ' + 'item or be set to `true`'); this._exceptConditionals = options.allExcept.indexOf('conditionals') > -1; this._exceptFunctions = options.allExcept.indexOf('functions') > -1; } |
| ✓ Negative was executed (else) | }··· if (options.open || options.close) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options.open || options.close) {··· assert(typeof options.open === 'boolean' && typeof options.close === 'boolean', this.getOptionName() + ' option requires the "open" and "close" ' + 'properties to be booleans'); this._checkOpen = options.open; this._checkClose = options.close; } |
| ✓ Negative was executed (else) | }··· } else { |
| Branch LogicalExpression | |
| ✓ Was returned | if (options.open || options.close) { |
| ✓ Was returned | if (options.open || options.close) { |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | assert(typeof options.open === 'boolean' && typeof options.close === 'boolean', |
| ✗ Was not returned | assert(typeof options.open === 'boolean' && typeof options.close === 'boolean', |
| Function (anonymous_502) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowPaddingNewlinesInBlocks'; }, |
| Function (anonymous_503) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var exceptConditionals = this._exceptConditionals; var exceptFunctions = this._exceptFunctions; var checkOpen = this._checkOpen; var checkClose = this._checkClose; file.iterateNodesByType('BlockStatement', function(node) { var openingBracket; var closingBracket; if (exceptConditionals && node.parentNode.type === 'IfStatement' || exceptFunctions && (node.parentNode.type === 'FunctionExpression' || node.parentNode.type === 'FunctionDeclaration')) { return; } if (checkOpen === true) { openingBracket = file.getFirstNodeToken(node); errors.assert.linesBetween({ token: openingBracket, nextToken: file.getNextToken(openingBracket, {includeComments: true}), atMost: 1, message: 'Expected no padding newline after opening curly brace' }); } if (checkClose === true) { closingBracket = file.getLastNodeToken(node); errors.assert.linesBetween({ token: file.getPrevToken(closingBracket, {includeComments: true}), nextToken: closingBracket, atMost: 1, message: 'Expected no padding newline before closing curly brace' }); } }); } |
| Function (anonymous_504) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('BlockStatement', function(node) {··· var openingBracket; var closingBracket; if (exceptConditionals && node.parentNode.type === 'IfStatement' || exceptFunctions && (node.parentNode.type === 'FunctionExpression' || node.parentNode.type === 'FunctionDeclaration')) { return; } if (checkOpen === true) { openingBracket = file.getFirstNodeToken(node); errors.assert.linesBetween({ token: openingBracket, nextToken: file.getNextToken(openingBracket, {includeComments: true}), atMost: 1, message: 'Expected no padding newline after opening curly brace' }); } if (checkClose === true) { closingBracket = file.getLastNodeToken(node); errors.assert.linesBetween({ token: file.getPrevToken(closingBracket, {includeComments: true}), nextToken: closingBracket, atMost: 1, message: 'Expected no padding newline before closing curly brace' }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | node.parentNode.type === 'FunctionDeclaration')) {··· return; } |
| ✓ Negative was executed (else) | }··· if (checkOpen === true) { |
| Branch LogicalExpression | |
| ✓ Was returned | exceptFunctions && (node.parentNode.type === 'FunctionExpression' ||··· node.parentNode.type === 'FunctionDeclaration')) { |
| ✓ Was returned | if (exceptConditionals && node.parentNode.type === 'IfStatement' || |
| Branch LogicalExpression | |
| ✓ Was returned | if (exceptConditionals && node.parentNode.type === 'IfStatement' || |
| ✓ Was returned | if (exceptConditionals && node.parentNode.type === 'IfStatement' || |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | exceptFunctions && (node.parentNode.type === 'FunctionExpression' ||··· node.parentNode.type === 'FunctionDeclaration')) { |
| ✓ Was returned | exceptFunctions && (node.parentNode.type === 'FunctionExpression' || |
| Branch LogicalExpression | |
| ✓ Was returned | node.parentNode.type === 'FunctionDeclaration')) { |
| ✓ Was returned | exceptFunctions && (node.parentNode.type === 'FunctionExpression' || |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (checkOpen === true) {··· openingBracket = file.getFirstNodeToken(node); errors.assert.linesBetween({ token: openingBracket, nextToken: file.getNextToken(openingBracket, {includeComments: true}), atMost: 1, message: 'Expected no padding newline after opening curly brace' }); } |
| ✓ Negative was executed (else) | }··· if (checkClose === true) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (checkClose === true) {··· closingBracket = file.getLastNodeToken(node); errors.assert.linesBetween({ token: file.getPrevToken(closingBracket, {includeComments: true}), nextToken: closingBracket, atMost: 1, message: 'Expected no padding newline before closing curly brace' }); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_505) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_506) | |
|---|---|
| ✓ Was called | configure: function(value) {··· assert( value === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_507) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowPaddingNewLinesInObjects'; }, |
| Function (anonymous_508) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('ObjectExpression', function(node) { var openingBracket = file.getFirstNodeToken(node); var nextToken = file.getNextToken(openingBracket); if (nextToken.type === 'Punctuator' && nextToken.value === '}') { return; } errors.assert.sameLine({ token: openingBracket, nextToken: nextToken, message: 'Illegal newline after opening curly brace' }); var closingBracket = file.getLastNodeToken(node); errors.assert.sameLine({ token: file.getPrevToken(closingBracket), nextToken: closingBracket, message: 'Illegal newline before closing curly brace' }); }); } |
| Function (anonymous_509) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('ObjectExpression', function(node) {··· var openingBracket = file.getFirstNodeToken(node); var nextToken = file.getNextToken(openingBracket); if (nextToken.type === 'Punctuator' && nextToken.value === '}') { return; } errors.assert.sameLine({ token: openingBracket, nextToken: nextToken, message: 'Illegal newline after opening curly brace' }); var closingBracket = file.getLastNodeToken(node); errors.assert.sameLine({ token: file.getPrevToken(closingBracket), nextToken: closingBracket, message: 'Illegal newline before closing curly brace' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (nextToken.type === 'Punctuator' && nextToken.value === '}') {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.sameLine({ |
| Branch LogicalExpression | |
| ✓ Was returned | if (nextToken.type === 'Punctuator' && nextToken.value === '}') { |
| ✓ Was returned | if (nextToken.type === 'Punctuator' && nextToken.value === '}') { |
| Function (anonymous_510) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_511) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_512) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowParenthesesAroundArrowParam'; }, |
| Function (anonymous_513) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· function isWrapped(node) { var openParensToken = file.getPrevToken(file.getFirstNodeToken(node)); var closingParensToken = file.getNextToken(file.getLastNodeToken(node)); var closingTokenValue = closingParensToken ? closingParensToken.value : ''; return openParensToken.value + closingTokenValue === '()'; } file.iterateNodesByType('ArrowFunctionExpression', function(node) { if (node.params.length !== 1) { return; } var firstParam = node.params[0]; // Old Esprima var hasDefaultParameter = node.defaults && node.defaults.length === 1; // ESTree var hasDefaultParameterESTree = firstParam.type === 'AssignmentPattern'; var hasDestructuring = firstParam.type === 'ObjectPattern' || firstParam.type === 'ArrayPattern'; var hasRestElement = firstParam.type === 'RestElement'; if (hasDefaultParameter || hasDefaultParameterESTree || hasDestructuring || hasRestElement) { return; } if (isWrapped(firstParam)) { errors.add( 'Illegal wrap of arrow function expressions in parentheses', firstParam.loc.start ); } }); } |
| Function isWrapped | |
|---|---|
| ✓ Was called | function isWrapped(node) {··· var openParensToken = file.getPrevToken(file.getFirstNodeToken(node)); var closingParensToken = file.getNextToken(file.getLastNodeToken(node)); var closingTokenValue = closingParensToken ? closingParensToken.value : ''; return openParensToken.value + closingTokenValue === '()'; } |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | var closingTokenValue = closingParensToken ? closingParensToken.value : ''; |
| ✗ Negative was not returned (: ...) | var closingTokenValue = closingParensToken ? closingParensToken.value : ''; |
| Function (anonymous_515) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('ArrowFunctionExpression', function(node) {··· if (node.params.length !== 1) { return; } var firstParam = node.params[0]; // Old Esprima var hasDefaultParameter = node.defaults && node.defaults.length === 1; // ESTree var hasDefaultParameterESTree = firstParam.type === 'AssignmentPattern'; var hasDestructuring = firstParam.type === 'ObjectPattern' || firstParam.type === 'ArrayPattern'; var hasRestElement = firstParam.type === 'RestElement'; if (hasDefaultParameter || hasDefaultParameterESTree || hasDestructuring || hasRestElement) { return; } if (isWrapped(firstParam)) { errors.add( 'Illegal wrap of arrow function expressions in parentheses', firstParam.loc.start ); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.params.length !== 1) {··· return; } |
| ✓ Negative was executed (else) | }··· var firstParam = node.params[0]; |
| Branch LogicalExpression | |
|---|---|
| ✗ Was not returned | var hasDefaultParameter = node.defaults && node.defaults.length === 1; |
| ✓ Was returned | var hasDefaultParameter = node.defaults && node.defaults.length === 1; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | var hasDestructuring = firstParam.type === 'ObjectPattern' || firstParam.type === 'ArrayPattern'; |
| ✓ Was returned | var hasDestructuring = firstParam.type === 'ObjectPattern' || firstParam.type === 'ArrayPattern'; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | hasRestElement) {··· return; } |
| ✓ Negative was executed (else) | }··· if (isWrapped(firstParam)) { |
| Branch LogicalExpression | |
| ✓ Was returned | hasRestElement) { |
| ✓ Was returned | if (hasDefaultParameter ||··· hasDefaultParameterESTree || hasDestructuring || |
| Branch LogicalExpression | |
| ✓ Was returned | hasDestructuring || |
| ✓ Was returned | if (hasDefaultParameter ||··· hasDefaultParameterESTree || |
| Branch LogicalExpression | |
| ✓ Was returned | hasDefaultParameterESTree || |
| ✗ Was not returned | if (hasDefaultParameter || |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isWrapped(firstParam)) {··· errors.add( 'Illegal wrap of arrow function expressions in parentheses', firstParam.loc.start ); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_516) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_517) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true || options === 'allButReserved' || typeof options === 'object', this.getOptionName() + ' option requires a true value or an object' ); this._exceptReserved = options === 'allButReserved'; if (Array.isArray(options.allExcept)) { this._exceptReserved = options.allExcept.indexOf('reserved') !== -1; } }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options === true || options === 'allButReserved' || typeof options === 'object', |
| ✓ Was returned | options === true || options === 'allButReserved' || typeof options === 'object', |
| Branch LogicalExpression | |
| ✓ Was returned | options === true || options === 'allButReserved' || typeof options === 'object', |
| ✓ Was returned | options === true || options === 'allButReserved' || typeof options === 'object', |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (Array.isArray(options.allExcept)) {··· this._exceptReserved = options.allExcept.indexOf('reserved') !== -1; } |
| ✓ Negative was executed (else) | }··· }, |
| Function (anonymous_518) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowQuotedKeysInObjects'; }, |
| Function (anonymous_519) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var KEY_NAME_RE = /^(0|[1-9][0-9]*|[a-zA-Z_$]+[\w$]*)$/; // number or identifier var exceptReserved = this._exceptReserved; file.iterateNodesByType('ObjectExpression', function(node) { node.properties.forEach(function(prop) { var key = prop.key; if (key.type === 'Literal' && typeof key.value === 'string' && KEY_NAME_RE.test(key.value) ) { if (exceptReserved && reservedWords.check(key.value, file.getDialect(), true)) { return; } errors.cast({ message: 'Extra quotes for key', column: prop.loc.start.column, line: prop.loc.start.line, additional: prop }); } }); }); }, |
| Function (anonymous_520) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('ObjectExpression', function(node) {··· node.properties.forEach(function(prop) { var key = prop.key; if (key.type === 'Literal' && typeof key.value === 'string' && KEY_NAME_RE.test(key.value) ) { if (exceptReserved && reservedWords.check(key.value, file.getDialect(), true)) { return; } errors.cast({ message: 'Extra quotes for key', column: prop.loc.start.column, line: prop.loc.start.line, additional: prop }); } }); }); |
| Function (anonymous_521) | |
|---|---|
| ✓ Was called | node.properties.forEach(function(prop) {··· var key = prop.key; if (key.type === 'Literal' && typeof key.value === 'string' && KEY_NAME_RE.test(key.value) ) { if (exceptReserved && reservedWords.check(key.value, file.getDialect(), true)) { return; } errors.cast({ message: 'Extra quotes for key', column: prop.loc.start.column, line: prop.loc.start.line, additional: prop }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | ) {··· if (exceptReserved && reservedWords.check(key.value, file.getDialect(), true)) { return; } errors.cast({ message: 'Extra quotes for key', column: prop.loc.start.column, line: prop.loc.start.line, additional: prop }); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | KEY_NAME_RE.test(key.value) |
| ✓ Was returned | if (key.type === 'Literal' &&··· typeof key.value === 'string' && |
| Branch LogicalExpression | |
| ✓ Was returned | typeof key.value === 'string' && |
| ✓ Was returned | if (key.type === 'Literal' && |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (exceptReserved && reservedWords.check(key.value, file.getDialect(), true)) {··· return; } |
| ✓ Negative was executed (else) | }··· errors.cast({ |
| Branch LogicalExpression | |
| ✓ Was returned | if (exceptReserved && reservedWords.check(key.value, file.getDialect(), true)) { |
| ✓ Was returned | if (exceptReserved && reservedWords.check(key.value, file.getDialect(), true)) { |
| Function (anonymous_522) | |
|---|---|
| ✓ Was called | _fix: function(file, error) {··· var node = error.additional; var token = file.getFirstNodeToken(node); token.value = token.value.slice(1, -1); } |
| Function (anonymous_523) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_524) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_525) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSemicolons'; }, |
| Function (anonymous_526) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateTokensByTypeAndValue('Punctuator', ';', function(token) { var nextToken = file.getNextToken(token); var node = file.getNodeByRange(token.range[0]); // Ignore node exceptions if (node.type in nodeExceptions) { return; } // Ignore next token exceptions if (nextToken.value in tokenExceptions) { return; } if (nextToken.type === 'EOF' || nextToken.loc.end.line > token.loc.end.line) { errors.cast({ message: 'semicolons are disallowed at the end of a line.', line: token.loc.end.line, column: token.loc.end.column, additional: token }); } }); }, |
| Function (anonymous_527) | |
|---|---|
| ✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ';', function(token) {··· var nextToken = file.getNextToken(token); var node = file.getNodeByRange(token.range[0]); // Ignore node exceptions if (node.type in nodeExceptions) { return; } // Ignore next token exceptions if (nextToken.value in tokenExceptions) { return; } if (nextToken.type === 'EOF' || nextToken.loc.end.line > token.loc.end.line) { errors.cast({ message: 'semicolons are disallowed at the end of a line.', line: token.loc.end.line, column: token.loc.end.column, additional: token }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.type in nodeExceptions) {··· return; } |
| ✓ Negative was executed (else) | }··· // Ignore next token exceptions |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (nextToken.value in tokenExceptions) {··· return; } |
| ✓ Negative was executed (else) | }··· if (nextToken.type === 'EOF' || nextToken.loc.end.line > token.loc.end.line) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (nextToken.type === 'EOF' || nextToken.loc.end.line > token.loc.end.line) {··· errors.cast({ message: 'semicolons are disallowed at the end of a line.', line: token.loc.end.line, column: token.loc.end.column, additional: token }); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | if (nextToken.type === 'EOF' || nextToken.loc.end.line > token.loc.end.line) { |
| ✓ Was returned | if (nextToken.type === 'EOF' || nextToken.loc.end.line > token.loc.end.line) { |
| Function (anonymous_528) | |
|---|---|
| ✓ Was called | _fix: function(file, error) {··· file.removeToken(error.additional); } |
| Function (anonymous_529) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_530) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_531) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowShorthandArrowFunctions'; }, |
| Function (anonymous_532) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('ArrowFunctionExpression', function(node) { if (node.expression) { errors.add( 'Use arrow function with explicit block and explicit return', node.body.loc.start ); } }); } |
| Function (anonymous_533) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('ArrowFunctionExpression', function(node) {··· if (node.expression) { errors.add( 'Use arrow function with explicit block and explicit return', node.body.loc.start ); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.expression) {··· errors.add( 'Use arrow function with explicit block and explicit return', node.body.loc.start ); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_534) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_535) | |
|---|---|
| ✓ Was called | configure: function(operators) {··· var isTrue = operators === true; assert( Array.isArray(operators) || isTrue, this.getOptionName() + ' option requires array or true value' ); if (isTrue) { operators = allOperators; } this._operatorIndex = {}; for (var i = 0, l = operators.length; i < l; i++) { this._operatorIndex[operators[i]] = true; } }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | Array.isArray(operators) || isTrue, |
| ✓ Was returned | Array.isArray(operators) || isTrue, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isTrue) {··· operators = allOperators; } |
| ✓ Negative was executed (else) | }··· this._operatorIndex = {}; |
| Function (anonymous_536) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpaceAfterBinaryOperators'; }, |
| Function (anonymous_537) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var operators = this._operatorIndex; // Comma if (operators[',']) { file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { if (file.getNextToken(token).value === ',') { return; } errors.assert.noWhitespaceBetween({ token: token, nextToken: file.getNextToken(token), message: 'Operator , should stick to following expression' }); }); } // For everything else file.iterateNodesByType( ['BinaryExpression', 'AssignmentExpression', 'VariableDeclarator', 'LogicalExpression'], function(node) { var operator; var expression; if (node.type === 'VariableDeclarator') { expression = node.init; operator = '='; } else { operator = node.operator; expression = node.right; } if (expression === null) { return; } var operatorToken = file.findPrevOperatorToken( file.getFirstNodeToken(expression), operator ); var nextToken = file.getNextToken(operatorToken); if (operators[operator]) { errors.assert.noWhitespaceBetween({ token: operatorToken, nextToken: nextToken, message: 'Operator ' + operator + ' should stick to following expression' }); } } ); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (operators[',']) {··· file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { if (file.getNextToken(token).value === ',') { return; } errors.assert.noWhitespaceBetween({ token: token, nextToken: file.getNextToken(token), message: 'Operator , should stick to following expression' }); }); } |
| ✓ Negative was executed (else) | }··· // For everything else |
| Function (anonymous_538) | |
|---|---|
| ✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) {··· if (file.getNextToken(token).value === ',') { return; } errors.assert.noWhitespaceBetween({ token: token, nextToken: file.getNextToken(token), message: 'Operator , should stick to following expression' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (file.getNextToken(token).value === ',') {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
| Function (anonymous_539) | |
|---|---|
| ✓ Was called | function(node) {··· var operator; var expression; if (node.type === 'VariableDeclarator') { expression = node.init; operator = '='; } else { operator = node.operator; expression = node.right; } if (expression === null) { return; } var operatorToken = file.findPrevOperatorToken( file.getFirstNodeToken(expression), operator ); var nextToken = file.getNextToken(operatorToken); if (operators[operator]) { errors.assert.noWhitespaceBetween({ token: operatorToken, nextToken: nextToken, message: 'Operator ' + operator + ' should stick to following expression' }); } } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.type === 'VariableDeclarator') {··· expression = node.init; operator = '='; } else { |
| ✓ Negative was executed (else) | } else {··· operator = node.operator; expression = node.right; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (expression === null) {··· return; } |
| ✓ Negative was executed (else) | }··· var operatorToken = file.findPrevOperatorToken( |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (operators[operator]) {··· errors.assert.noWhitespaceBetween({ token: operatorToken, nextToken: nextToken, message: 'Operator ' + operator + ' should stick to following expression' }); } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_540) | |
|---|---|
| ✓ Was called | module.exports = function() {··· }; |
| Function (anonymous_541) | |
|---|---|
| ✓ Was called | configure: function(options) {··· if (typeof options !== 'object') { assert( options === true, this.getOptionName() + ' option requires true value or an object' ); var _options = {allExcept: []}; return this.configure(_options); } assert( Array.isArray(options.allExcept), ' property `allExcept` in ' + this.getOptionName() + ' should be an array of strings' ); this._exceptSparseArrays = options.allExcept.indexOf('sparseArrays') >= 0; }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof options !== 'object') {··· assert( options === true, this.getOptionName() + ' option requires true value or an object' ); var _options = {allExcept: []}; return this.configure(_options); } |
| ✓ Negative was executed (else) | }··· assert( |
| Function (anonymous_542) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpaceAfterComma'; }, |
| Function (anonymous_543) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var exceptSparseArrays = this._exceptSparseArrays; file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { var nextToken = file.getNextToken(token); if (exceptSparseArrays && nextToken.value === ',') { return; } errors.assert.noWhitespaceBetween({ token: token, nextToken: nextToken, message: 'Illegal space after comma' }); }); } |
| Function (anonymous_544) | |
|---|---|
| ✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) {··· var nextToken = file.getNextToken(token); if (exceptSparseArrays && nextToken.value === ',') { return; } errors.assert.noWhitespaceBetween({ token: token, nextToken: nextToken, message: 'Illegal space after comma' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (exceptSparseArrays && nextToken.value === ',') {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
| Branch LogicalExpression | |
| ✓ Was returned | if (exceptSparseArrays && nextToken.value === ',') { |
| ✓ Was returned | if (exceptSparseArrays && nextToken.value === ',') { |
| Function (anonymous_545) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_546) | |
|---|---|
| ✓ Was called | configure: function(keywords) {··· assert( Array.isArray(keywords) || keywords === true, this.getOptionName() + ' option requires array or true value' ); if (keywords === true) { keywords = defaultKeywords; } this._keywords = keywords; }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | Array.isArray(keywords) || keywords === true, |
| ✓ Was returned | Array.isArray(keywords) || keywords === true, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (keywords === true) {··· keywords = defaultKeywords; } |
| ✓ Negative was executed (else) | }··· this._keywords = keywords; |
| Function (anonymous_547) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpaceAfterKeywords'; }, |
| Function (anonymous_548) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) { var nextToken = file.getNextToken(token); // Make an exception if the next token is not a Punctuator such as a Keyword or Identifier if (nextToken.type !== 'Punctuator') { return; } errors.assert.noWhitespaceBetween({ token: token, nextToken: nextToken }); }); } |
| Function (anonymous_549) | |
|---|---|
| ✓ Was called | file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) {··· var nextToken = file.getNextToken(token); // Make an exception if the next token is not a Punctuator such as a Keyword or Identifier if (nextToken.type !== 'Punctuator') { return; } errors.assert.noWhitespaceBetween({ token: token, nextToken: nextToken }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (nextToken.type !== 'Punctuator') {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
| Function (anonymous_550) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_551) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_552) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpaceAfterLineComment'; }, |
| Function (anonymous_553) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateTokensByType('Line', function(comment) { var value = comment.value; if (value.length > 0 && value[0] === ' ') { errors.add('Illegal space after line comment', comment.loc.start); } }); } |
| Function (anonymous_554) | |
|---|---|
| ✓ Was called | file.iterateTokensByType('Line', function(comment) {··· var value = comment.value; if (value.length > 0 && value[0] === ' ') { errors.add('Illegal space after line comment', comment.loc.start); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value.length > 0 && value[0] === ' ') {··· errors.add('Illegal space after line comment', comment.loc.start); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | if (value.length > 0 && value[0] === ' ') { |
| ✓ Was returned | if (value.length > 0 && value[0] === ' ') { |
| Function (anonymous_555) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_556) | |
|---|---|
| ✓ Was called | configure: function(options) {··· if (typeof options !== 'object') { assert( options === true || options === 'ignoreSingleLine' || options === 'ignoreMultiLine', this.getOptionName() + ' option requires a true value, "ignoreSingleLine", "ignoreMultiLine", or an object' ); var _options = { allExcept: [] }; if (options === 'ignoreSingleLine') { _options.allExcept.push('singleline'); } if (options === 'ignoreMultiLine') { _options.allExcept.push('multiline'); } return this.configure(_options); } else { assert( Array.isArray(options.allExcept), this.getOptionName() + ' option object requires allExcept array property' ); } this._exceptSingleline = options.allExcept.indexOf('singleline') > -1; this._exceptMultiline = options.allExcept.indexOf('multiline') > -1; this._exceptAligned = options.allExcept.indexOf('aligned') > -1; this._exceptMethod = options.allExcept.indexOf('method') > -1; assert( !this._exceptMultiline || !this._exceptAligned, this.getOptionName() + ' option allExcept property cannot contain `aligned` and `multiline` at the same time' ); assert( !this._exceptMultiline || !this._exceptSingleline, this.getOptionName() + ' option allExcept property cannot contain `singleline` and `multiline` at the same time' ); }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof options !== 'object') {··· assert( options === true || options === 'ignoreSingleLine' || options === 'ignoreMultiLine', this.getOptionName() + ' option requires a true value, "ignoreSingleLine", "ignoreMultiLine", or an object' ); var _options = { allExcept: [] }; if (options === 'ignoreSingleLine') { _options.allExcept.push('singleline'); } if (options === 'ignoreMultiLine') { _options.allExcept.push('multiline'); } return this.configure(_options); } else { |
| ✓ Negative was executed (else) | } else {··· assert( Array.isArray(options.allExcept), this.getOptionName() + ' option object requires allExcept array property' ); } |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options === 'ignoreMultiLine', |
| ✓ Was returned | options === true ||··· options === 'ignoreSingleLine' || |
| Branch LogicalExpression | |
| ✓ Was returned | options === 'ignoreSingleLine' || |
| ✓ Was returned | options === true || |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options === 'ignoreSingleLine') {··· _options.allExcept.push('singleline'); } |
| ✓ Negative was executed (else) | }··· if (options === 'ignoreMultiLine') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options === 'ignoreMultiLine') {··· _options.allExcept.push('multiline'); } |
| ✓ Negative was executed (else) | }··· return this.configure(_options); |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | !this._exceptMultiline || !this._exceptAligned, |
| ✓ Was returned | !this._exceptMultiline || !this._exceptAligned, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | !this._exceptMultiline || !this._exceptSingleline, |
| ✓ Was returned | !this._exceptMultiline || !this._exceptSingleline, |
| Function (anonymous_557) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpaceAfterObjectKeys'; }, |
| Function (anonymous_558) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var exceptSingleline = this._exceptSingleline; var exceptMultiline = this._exceptMultiline; var exceptAligned = this._exceptAligned; var exceptMethod = this._exceptMethod; file.iterateNodesByType('ObjectExpression', function(node) { var multiline = node.loc.start.line !== node.loc.end.line; if (exceptSingleline && !multiline) { return; } if (exceptMultiline && multiline) { return; } var maxKeyEndPos = 0; var tokens = []; node.properties.forEach(function(property) { if (property.shorthand || property.kind !== 'init' || (exceptMethod && property.method) || node.type === 'SpreadProperty') { return; } var keyToken = file.getLastNodeToken(property.key); if (property.computed === true) { keyToken = file.getNextToken(keyToken); } if (exceptAligned) { maxKeyEndPos = Math.max(maxKeyEndPos, keyToken.loc.end.column); } tokens.push(keyToken); }); var noSpace = true; if (exceptAligned) { var withoutSpace = 0; var alignedOnColon = 0; tokens.forEach(function(key) { var colon = file.getNextToken(key); var spaces = Math.abs(colon.range[0] - key.range[1]); if (spaces === 0) { withoutSpace++; } else if (spaces === maxKeyEndPos - key.loc.end.column) { alignedOnColon++; } }); noSpace = withoutSpace > alignedOnColon; } tokens.forEach(function(key) { var colon = file.getNextToken(key); var spaces = (exceptAligned && !noSpace) ? maxKeyEndPos - key.loc.end.column : 0; errors.assert.spacesBetween({ token: key, nextToken: colon, exactly: spaces, message: 'Illegal space after key', disallowNewLine: true }); }); }); } |
| Function (anonymous_559) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('ObjectExpression', function(node) {··· var multiline = node.loc.start.line !== node.loc.end.line; if (exceptSingleline && !multiline) { return; } if (exceptMultiline && multiline) { return; } var maxKeyEndPos = 0; var tokens = []; node.properties.forEach(function(property) { if (property.shorthand || property.kind !== 'init' || (exceptMethod && property.method) || node.type === 'SpreadProperty') { return; } var keyToken = file.getLastNodeToken(property.key); if (property.computed === true) { keyToken = file.getNextToken(keyToken); } if (exceptAligned) { maxKeyEndPos = Math.max(maxKeyEndPos, keyToken.loc.end.column); } tokens.push(keyToken); }); var noSpace = true; if (exceptAligned) { var withoutSpace = 0; var alignedOnColon = 0; tokens.forEach(function(key) { var colon = file.getNextToken(key); var spaces = Math.abs(colon.range[0] - key.range[1]); if (spaces === 0) { withoutSpace++; } else if (spaces === maxKeyEndPos - key.loc.end.column) { alignedOnColon++; } }); noSpace = withoutSpace > alignedOnColon; } tokens.forEach(function(key) { var colon = file.getNextToken(key); var spaces = (exceptAligned && !noSpace) ? maxKeyEndPos - key.loc.end.column : 0; errors.assert.spacesBetween({ token: key, nextToken: colon, exactly: spaces, message: 'Illegal space after key', disallowNewLine: true }); }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (exceptSingleline && !multiline) {··· return; } |
| ✓ Negative was executed (else) | }··· if (exceptMultiline && multiline) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (exceptSingleline && !multiline) { |
| ✓ Was returned | if (exceptSingleline && !multiline) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (exceptMultiline && multiline) {··· return; } |
| ✓ Negative was executed (else) | }··· var maxKeyEndPos = 0; |
| Branch LogicalExpression | |
| ✓ Was returned | if (exceptMultiline && multiline) { |
| ✓ Was returned | if (exceptMultiline && multiline) { |
| Function (anonymous_560) | |
|---|---|
| ✓ Was called | node.properties.forEach(function(property) {··· if (property.shorthand || property.kind !== 'init' || (exceptMethod && property.method) || node.type === 'SpreadProperty') { return; } var keyToken = file.getLastNodeToken(property.key); if (property.computed === true) { keyToken = file.getNextToken(keyToken); } if (exceptAligned) { maxKeyEndPos = Math.max(maxKeyEndPos, keyToken.loc.end.column); } tokens.push(keyToken); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | node.type === 'SpreadProperty') {··· return; } |
| ✓ Negative was executed (else) | }··· var keyToken = file.getLastNodeToken(property.key); |
| Branch LogicalExpression | |
| ✓ Was returned | node.type === 'SpreadProperty') { |
| ✓ Was returned | if (property.shorthand || property.kind !== 'init' ||··· (exceptMethod && property.method) || |
| Branch LogicalExpression | |
| ✓ Was returned | (exceptMethod && property.method) || |
| ✓ Was returned | if (property.shorthand || property.kind !== 'init' || |
| Branch LogicalExpression | |
| ✓ Was returned | if (property.shorthand || property.kind !== 'init' || |
| ✓ Was returned | if (property.shorthand || property.kind !== 'init' || |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | (exceptMethod && property.method) || |
| ✓ Was returned | (exceptMethod && property.method) || |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (property.computed === true) {··· keyToken = file.getNextToken(keyToken); } |
| ✓ Negative was executed (else) | }··· if (exceptAligned) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (exceptAligned) {··· maxKeyEndPos = Math.max(maxKeyEndPos, keyToken.loc.end.column); } |
| ✓ Negative was executed (else) | }··· tokens.push(keyToken); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (exceptAligned) {··· var withoutSpace = 0; var alignedOnColon = 0; tokens.forEach(function(key) { var colon = file.getNextToken(key); var spaces = Math.abs(colon.range[0] - key.range[1]); if (spaces === 0) { withoutSpace++; } else if (spaces === maxKeyEndPos - key.loc.end.column) { alignedOnColon++; } }); noSpace = withoutSpace > alignedOnColon; } |
| ✓ Negative was executed (else) | }··· tokens.forEach(function(key) { |
| Function (anonymous_561) | |
|---|---|
| ✓ Was called | tokens.forEach(function(key) {··· var colon = file.getNextToken(key); var spaces = Math.abs(colon.range[0] - key.range[1]); if (spaces === 0) { withoutSpace++; } else if (spaces === maxKeyEndPos - key.loc.end.column) { alignedOnColon++; } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (spaces === 0) {··· withoutSpace++; } else if (spaces === maxKeyEndPos - key.loc.end.column) { |
| ✓ Negative was executed (else) | } else if (spaces === maxKeyEndPos - key.loc.end.column) {··· alignedOnColon++; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (spaces === maxKeyEndPos - key.loc.end.column) {··· alignedOnColon++; } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_562) | |
|---|---|
| ✓ Was called | tokens.forEach(function(key) {··· var colon = file.getNextToken(key); var spaces = (exceptAligned && !noSpace) ? maxKeyEndPos - key.loc.end.column : 0; errors.assert.spacesBetween({ token: key, nextToken: colon, exactly: spaces, message: 'Illegal space after key', disallowNewLine: true }); }); |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | var spaces = (exceptAligned && !noSpace) ? maxKeyEndPos - key.loc.end.column : 0; |
| ✓ Negative was returned (: ...) | var spaces = (exceptAligned && !noSpace) ? maxKeyEndPos - key.loc.end.column : 0; |
| Branch LogicalExpression | |
| ✓ Was returned | var spaces = (exceptAligned && !noSpace) ? maxKeyEndPos - key.loc.end.column : 0; |
| ✓ Was returned | var spaces = (exceptAligned && !noSpace) ? maxKeyEndPos - key.loc.end.column : 0; |
| Function (anonymous_563) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_564) | |
|---|---|
| ✓ Was called | configure: function(operators) {··· var isTrue = operators === true; assert( Array.isArray(operators) || isTrue, this.getOptionName() + ' option requires array or true value' ); if (isTrue) { operators = defaultOperators; } this._operatorIndex = {}; for (var i = 0, l = operators.length; i < l; i++) { this._operatorIndex[operators[i]] = true; } }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | Array.isArray(operators) || isTrue, |
| ✓ Was returned | Array.isArray(operators) || isTrue, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isTrue) {··· operators = defaultOperators; } |
| ✓ Negative was executed (else) | }··· this._operatorIndex = {}; |
| Function (anonymous_565) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpaceAfterPrefixUnaryOperators'; }, |
| Function (anonymous_566) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var operatorIndex = this._operatorIndex; file.iterateNodesByType(['UnaryExpression', 'UpdateExpression'], function(node) { // Check "node.prefix" for prefix type of (inc|dec)rement if (node.prefix && operatorIndex[node.operator]) { var operatorToken = file.getFirstNodeToken(node); errors.assert.noWhitespaceBetween({ token: operatorToken, nextToken: file.getNextToken(operatorToken), message: 'Operator ' + node.operator + ' should stick to operand' }); } }); } |
| Function (anonymous_567) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['UnaryExpression', 'UpdateExpression'], function(node) {··· // Check "node.prefix" for prefix type of (inc|dec)rement if (node.prefix && operatorIndex[node.operator]) { var operatorToken = file.getFirstNodeToken(node); errors.assert.noWhitespaceBetween({ token: operatorToken, nextToken: file.getNextToken(operatorToken), message: 'Operator ' + node.operator + ' should stick to operand' }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.prefix && operatorIndex[node.operator]) {··· var operatorToken = file.getFirstNodeToken(node); errors.assert.noWhitespaceBetween({ token: operatorToken, nextToken: file.getNextToken(operatorToken), message: 'Operator ' + node.operator + ' should stick to operand' }); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | if (node.prefix && operatorIndex[node.operator]) { |
| ✓ Was returned | if (node.prefix && operatorIndex[node.operator]) { |
| Function (anonymous_568) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_569) | |
|---|---|
| ✓ Was called | configure: function(operators) {··· var isTrue = operators === true; assert( Array.isArray(operators) || isTrue, this.getOptionName() + ' option requires array or true value' ); if (isTrue) { operators = allOperators; } this._operatorIndex = {}; for (var i = 0, l = operators.length; i < l; i++) { this._operatorIndex[operators[i]] = true; } }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | Array.isArray(operators) || isTrue, |
| ✓ Was returned | Array.isArray(operators) || isTrue, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isTrue) {··· operators = allOperators; } |
| ✓ Negative was executed (else) | }··· this._operatorIndex = {}; |
| Function (anonymous_570) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpaceBeforeBinaryOperators'; }, |
| Function (anonymous_571) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var operators = this._operatorIndex; // Comma if (operators[',']) { file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { if (file.getPrevToken(token).value === ',') { return; } errors.assert.noWhitespaceBetween({ token: file.getPrevToken(token, {includeComments: true}), nextToken: token, message: 'Operator , should stick to previous expression' }); }); } // For everything else file.iterateNodesByType( ['BinaryExpression', 'AssignmentExpression', 'VariableDeclarator', 'LogicalExpression'], function(node) { var operator; var expression; if (node.type === 'VariableDeclarator') { expression = node.init; operator = '='; } else { operator = node.operator; expression = node.right; } if (expression === null) { return; } var operatorToken = file.findPrevOperatorToken( file.getFirstNodeToken(expression), operator ); var prevToken = file.getPrevToken(operatorToken, {includeComments: true}); if (operators[operator]) { errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: operatorToken, message: 'Operator ' + node.operator + ' should stick to previous expression' }); } } ); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (operators[',']) {··· file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { if (file.getPrevToken(token).value === ',') { return; } errors.assert.noWhitespaceBetween({ token: file.getPrevToken(token, {includeComments: true}), nextToken: token, message: 'Operator , should stick to previous expression' }); }); } |
| ✓ Negative was executed (else) | }··· // For everything else |
| Function (anonymous_572) | |
|---|---|
| ✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) {··· if (file.getPrevToken(token).value === ',') { return; } errors.assert.noWhitespaceBetween({ token: file.getPrevToken(token, {includeComments: true}), nextToken: token, message: 'Operator , should stick to previous expression' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (file.getPrevToken(token).value === ',') {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
| Function (anonymous_573) | |
|---|---|
| ✓ Was called | function(node) {··· var operator; var expression; if (node.type === 'VariableDeclarator') { expression = node.init; operator = '='; } else { operator = node.operator; expression = node.right; } if (expression === null) { return; } var operatorToken = file.findPrevOperatorToken( file.getFirstNodeToken(expression), operator ); var prevToken = file.getPrevToken(operatorToken, {includeComments: true}); if (operators[operator]) { errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: operatorToken, message: 'Operator ' + node.operator + ' should stick to previous expression' }); } } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.type === 'VariableDeclarator') {··· expression = node.init; operator = '='; } else { |
| ✓ Negative was executed (else) | } else {··· operator = node.operator; expression = node.right; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (expression === null) {··· return; } |
| ✓ Negative was executed (else) | }··· var operatorToken = file.findPrevOperatorToken( |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (operators[operator]) {··· errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: operatorToken, message: 'Operator ' + node.operator + ' should stick to previous expression' }); } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_574) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_575) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_576) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpaceBeforeBlockStatements'; }, |
| Function (anonymous_577) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('BlockStatement', function(node) { if (isBareBlock(node)) { return; } var first = file.getFirstNodeToken(node); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(first), nextToken: first, disallowNewLine: true, message: 'Extra space before opening curly brace for block expressions' }); }); } |
| Function (anonymous_578) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('BlockStatement', function(node) {··· if (isBareBlock(node)) { return; } var first = file.getFirstNodeToken(node); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(first), nextToken: first, disallowNewLine: true, message: 'Extra space before opening curly brace for block expressions' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isBareBlock(node)) {··· return; } |
| ✓ Negative was executed (else) | }··· var first = file.getFirstNodeToken(node); |
| Function isBareBlock | |
|---|---|
| ✓ Was called | function isBareBlock(node) {··· var parentNode = node.parentNode; return parentNode && parentNode.type === 'BlockStatement' || parentNode.type === 'Program' || parentNode.body && parentNode.body.type === 'BlockStatement' && Array.isArray(parentNode.body); } |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | parentNode.body && parentNode.body.type === 'BlockStatement' && Array.isArray(parentNode.body); |
| ✓ Was returned | return parentNode &&··· parentNode.type === 'BlockStatement' || parentNode.type === 'Program' || |
| Branch LogicalExpression | |
| ✓ Was returned | parentNode.type === 'Program' || |
| ✓ Was returned | return parentNode &&··· parentNode.type === 'BlockStatement' || |
| Branch LogicalExpression | |
| ✓ Was returned | parentNode.type === 'BlockStatement' || |
| ✗ Was not returned | return parentNode && |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | parentNode.body && parentNode.body.type === 'BlockStatement' && Array.isArray(parentNode.body); |
| ✓ Was returned | parentNode.body && parentNode.body.type === 'BlockStatement' && Array.isArray(parentNode.body); |
| Branch LogicalExpression | |
| ✓ Was returned | parentNode.body && parentNode.body.type === 'BlockStatement' && Array.isArray(parentNode.body); |
| ✓ Was returned | parentNode.body && parentNode.body.type === 'BlockStatement' && Array.isArray(parentNode.body); |
| Function (anonymous_580) | |
|---|---|
| ✓ Was called | module.exports = function() {··· }; |
| Function (anonymous_581) | |
|---|---|
| ✓ Was called | configure: function(options) {··· if (typeof options !== 'object') { assert( options === true, this.getOptionName() + ' option requires true value or an object' ); var _options = {allExcept: []}; return this.configure(_options); } assert( Array.isArray(options.allExcept), ' property `allExcept` in ' + this.getOptionName() + ' should be an array of strings' ); this._exceptSparseArrays = options.allExcept.indexOf('sparseArrays') >= 0; }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof options !== 'object') {··· assert( options === true, this.getOptionName() + ' option requires true value or an object' ); var _options = {allExcept: []}; return this.configure(_options); } |
| ✓ Negative was executed (else) | }··· assert( |
| Function (anonymous_582) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpaceBeforeComma'; }, |
| Function (anonymous_583) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var exceptSparseArrays = this._exceptSparseArrays; file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { var prevToken = file.getPrevToken(token); if (exceptSparseArrays && prevToken.value === ',') { return; } errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: token, message: 'Illegal space before comma' }); }); } |
| Function (anonymous_584) | |
|---|---|
| ✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) {··· var prevToken = file.getPrevToken(token); if (exceptSparseArrays && prevToken.value === ',') { return; } errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: token, message: 'Illegal space before comma' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (exceptSparseArrays && prevToken.value === ',') {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
| Branch LogicalExpression | |
| ✓ Was returned | if (exceptSparseArrays && prevToken.value === ',') { |
| ✓ Was returned | if (exceptSparseArrays && prevToken.value === ',') { |
| Function (anonymous_585) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_586) | |
|---|---|
| ✓ Was called | configure: function(keywords) {··· assert( Array.isArray(keywords) || keywords === true, this.getOptionName() + ' option requires array or true value'); if (keywords === true) { keywords = defaultKeywords; } this._keywords = keywords; }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | Array.isArray(keywords) || keywords === true, |
| ✓ Was returned | Array.isArray(keywords) || keywords === true, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (keywords === true) {··· keywords = defaultKeywords; } |
| ✓ Negative was executed (else) | }··· this._keywords = keywords; |
| Function (anonymous_587) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpaceBeforeKeywords'; }, |
| Function (anonymous_588) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) { var prevToken = file.getPrevToken(token, {includeComments: true}); if (!prevToken || prevToken.isComment) { return; } if (prevToken.type !== 'Keyword' && prevToken.value !== ';') { errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: token, message: 'Illegal space before "' + token.value + '" keyword' }); } }); } |
| Function (anonymous_589) | |
|---|---|
| ✓ Was called | file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) {··· var prevToken = file.getPrevToken(token, {includeComments: true}); if (!prevToken || prevToken.isComment) { return; } if (prevToken.type !== 'Keyword' && prevToken.value !== ';') { errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: token, message: 'Illegal space before "' + token.value + '" keyword' }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!prevToken || prevToken.isComment) {··· return; } |
| ✓ Negative was executed (else) | }··· if (prevToken.type !== 'Keyword' && prevToken.value !== ';') { |
| Branch LogicalExpression | |
| ✓ Was returned | if (!prevToken || prevToken.isComment) { |
| ✓ Was returned | if (!prevToken || prevToken.isComment) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (prevToken.type !== 'Keyword' && prevToken.value !== ';') {··· errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: token, message: 'Illegal space before "' + token.value + '" keyword' }); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | if (prevToken.type !== 'Keyword' && prevToken.value !== ';') { |
| ✓ Was returned | if (prevToken.type !== 'Keyword' && prevToken.value !== ';') { |
| Function (anonymous_590) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_591) | |
|---|---|
| ✓ Was called | configure: function(disallow) {··· assert( disallow === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_592) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpaceBeforeObjectValues'; }, |
| Function (anonymous_593) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('ObjectExpression', function(node) { node.properties.forEach(function(property) { if (property.shorthand || property.method || property.kind !== 'init' || node.type === 'SpreadProperty') { return; } var keyToken = file.getFirstNodeToken(property.key); var colon = file.findNextToken(keyToken, 'Punctuator', ':'); errors.assert.noWhitespaceBetween({ token: colon, nextToken: file.getNextToken(colon), message: 'Illegal space after key colon' }); }); }); } |
| Function (anonymous_594) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('ObjectExpression', function(node) {··· node.properties.forEach(function(property) { if (property.shorthand || property.method || property.kind !== 'init' || node.type === 'SpreadProperty') { return; } var keyToken = file.getFirstNodeToken(property.key); var colon = file.findNextToken(keyToken, 'Punctuator', ':'); errors.assert.noWhitespaceBetween({ token: colon, nextToken: file.getNextToken(colon), message: 'Illegal space after key colon' }); }); }); |
| Function (anonymous_595) | |
|---|---|
| ✓ Was called | node.properties.forEach(function(property) {··· if (property.shorthand || property.method || property.kind !== 'init' || node.type === 'SpreadProperty') { return; } var keyToken = file.getFirstNodeToken(property.key); var colon = file.findNextToken(keyToken, 'Punctuator', ':'); errors.assert.noWhitespaceBetween({ token: colon, nextToken: file.getNextToken(colon), message: 'Illegal space after key colon' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | node.type === 'SpreadProperty') {··· return; } |
| ✓ Negative was executed (else) | }··· var keyToken = file.getFirstNodeToken(property.key); |
| Branch LogicalExpression | |
| ✓ Was returned | node.type === 'SpreadProperty') { |
| ✓ Was returned | if (property.shorthand || property.method || property.kind !== 'init' || |
| Branch LogicalExpression | |
| ✓ Was returned | if (property.shorthand || property.method || property.kind !== 'init' || |
| ✓ Was returned | if (property.shorthand || property.method || property.kind !== 'init' || |
| Branch LogicalExpression | |
| ✓ Was returned | if (property.shorthand || property.method || property.kind !== 'init' || |
| ✓ Was returned | if (property.shorthand || property.method || property.kind !== 'init' || |
| Function (anonymous_596) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_597) | |
|---|---|
| ✓ Was called | configure: function(operators) {··· var isTrue = operators === true; assert( Array.isArray(operators) || isTrue, this.getOptionName() + ' option requires array or true value' ); if (isTrue) { operators = defaultOperators; } this._operatorIndex = {}; for (var i = 0, l = operators.length; i < l; i++) { this._operatorIndex[operators[i]] = true; } }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | Array.isArray(operators) || isTrue, |
| ✓ Was returned | Array.isArray(operators) || isTrue, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isTrue) {··· operators = defaultOperators; } |
| ✓ Negative was executed (else) | }··· this._operatorIndex = {}; |
| Function (anonymous_598) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpaceBeforePostfixUnaryOperators'; }, |
| Function (anonymous_599) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var operatorIndex = this._operatorIndex; // 'UpdateExpression' involve only ++ and -- operators file.iterateNodesByType('UpdateExpression', function(node) { // "!node.prefix" means postfix type of (inc|dec)rement if (!node.prefix && operatorIndex[node.operator]) { var operatorToken = file.getLastNodeToken(node); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(operatorToken), nextToken: operatorToken, message: 'Operator ' + node.operator + ' should stick to operand' }); } }); } |
| Function (anonymous_600) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('UpdateExpression', function(node) {··· // "!node.prefix" means postfix type of (inc|dec)rement if (!node.prefix && operatorIndex[node.operator]) { var operatorToken = file.getLastNodeToken(node); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(operatorToken), nextToken: operatorToken, message: 'Operator ' + node.operator + ' should stick to operand' }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!node.prefix && operatorIndex[node.operator]) {··· var operatorToken = file.getLastNodeToken(node); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(operatorToken), nextToken: operatorToken, message: 'Operator ' + node.operator + ' should stick to operand' }); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | if (!node.prefix && operatorIndex[node.operator]) { |
| ✓ Was returned | if (!node.prefix && operatorIndex[node.operator]) { |
| Function (anonymous_601) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_602) | |
|---|---|
| ✓ Was called | configure: function(value) {··· var isObject = typeof value === 'object'; var error = this.getOptionName() + ' rule requires string value true or object'; if (isObject) { assert('allExcept' in value, error); } else { assert(value === true, error); } this._exceptions = {}; if (isObject) { (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isObject) {··· assert('allExcept' in value, error); } else { |
| ✓ Negative was executed (else) | } else {··· assert(value === true, error); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isObject) {··· (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } |
| ✓ Negative was executed (else) | }··· }, |
| Function (anonymous_603) | |
|---|---|
| ✓ Was called | (value.allExcept || []).forEach(function(value) {··· this._exceptions[value] = true; }, this); |
| Branch LogicalExpression | |
| ✗ Was not returned | (value.allExcept || []).forEach(function(value) { |
| ✓ Was returned | (value.allExcept || []).forEach(function(value) { |
| Function (anonymous_604) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpaceBeforeSemicolon'; }, |
| Function (anonymous_605) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var exceptions = this._exceptions; file.iterateTokensByTypeAndValue('Punctuator', ';', function(token) { var prevToken = file.getPrevToken(token); if (!prevToken || prevToken.value in exceptions) { return; } errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: token, message: 'Illegal space before semicolon' }); }); } |
| Function (anonymous_606) | |
|---|---|
| ✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ';', function(token) {··· var prevToken = file.getPrevToken(token); if (!prevToken || prevToken.value in exceptions) { return; } errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: token, message: 'Illegal space before semicolon' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!prevToken || prevToken.value in exceptions) {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
| Branch LogicalExpression | |
| ✓ Was returned | if (!prevToken || prevToken.value in exceptions) { |
| ✓ Was returned | if (!prevToken || prevToken.value in exceptions) { |
| Function (anonymous_607) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_608) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_609) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpaceBetweenArguments'; }, |
| Function (anonymous_610) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType(['CallExpression'], function(node) { node.arguments.forEach(function(param) { var token = file.getFirstNodeToken(param); var punctuatorToken = file.getPrevToken(token); if (punctuatorToken.value === ',') { errors.assert.noWhitespaceBetween({ token: punctuatorToken, nextToken: file.getNextToken(punctuatorToken), message: 'Illegal space between arguments' }); } }); }); } |
| Function (anonymous_611) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['CallExpression'], function(node) {··· node.arguments.forEach(function(param) { var token = file.getFirstNodeToken(param); var punctuatorToken = file.getPrevToken(token); if (punctuatorToken.value === ',') { errors.assert.noWhitespaceBetween({ token: punctuatorToken, nextToken: file.getNextToken(punctuatorToken), message: 'Illegal space between arguments' }); } }); }); |
| Function (anonymous_612) | |
|---|---|
| ✓ Was called | node.arguments.forEach(function(param) {··· var token = file.getFirstNodeToken(param); var punctuatorToken = file.getPrevToken(token); if (punctuatorToken.value === ',') { errors.assert.noWhitespaceBetween({ token: punctuatorToken, nextToken: file.getNextToken(punctuatorToken), message: 'Illegal space between arguments' }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (punctuatorToken.value === ',') {··· errors.assert.noWhitespaceBetween({ token: punctuatorToken, nextToken: file.getNextToken(punctuatorToken), message: 'Illegal space between arguments' }); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_613) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_614) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( typeof options === 'object', this.getOptionName() + ' option must be the object' ); if ('beforeOpeningRoundBrace' in options) { assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } if ('beforeOpeningCurlyBrace' in options) { assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } assert( options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, this.getOptionName() + ' must have beforeOpeningCurlyBrace ' + ' or beforeOpeningRoundBrace property' ); this._beforeOpeningRoundBrace = Boolean(options.beforeOpeningRoundBrace); this._beforeOpeningCurlyBrace = Boolean(options.beforeOpeningCurlyBrace); }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('beforeOpeningRoundBrace' in options) {··· assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } |
| ✓ Negative was executed (else) | }··· if ('beforeOpeningCurlyBrace' in options) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('beforeOpeningCurlyBrace' in options) {··· assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } |
| ✓ Negative was executed (else) | }··· assert( |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
| ✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
| Function (anonymous_615) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpacesInAnonymousFunctionExpression'; }, |
| Function (anonymous_616) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var beforeOpeningRoundBrace = this._beforeOpeningRoundBrace; var beforeOpeningCurlyBrace = this._beforeOpeningCurlyBrace; file.iterateNodesByType(['FunctionExpression'], function(node) { var functionNode = node; var parent = node.parentNode; // Ignore syntactic sugar for getters and setters. if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { return; } // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { functionNode = parent.key; } // anonymous function expressions only if (node.id) { return; } if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } }); } |
| Function (anonymous_617) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['FunctionExpression'], function(node) {··· var functionNode = node; var parent = node.parentNode; // Ignore syntactic sugar for getters and setters. if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { return; } // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { functionNode = parent.key; } // anonymous function expressions only if (node.id) { return; } if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) {··· return; } |
| ✓ Negative was executed (else) | }··· // shorthand or constructor methods |
| Branch LogicalExpression | |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (parent.method || parent.type === 'MethodDefinition') {··· functionNode = parent.key; } |
| ✓ Negative was executed (else) | }··· // anonymous function expressions only |
| Branch LogicalExpression | |
| ✓ Was returned | if (parent.method || parent.type === 'MethodDefinition') { |
| ✓ Was returned | if (parent.method || parent.type === 'MethodDefinition') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.id) {··· return; } |
| ✓ Negative was executed (else) | }··· if (beforeOpeningRoundBrace) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (beforeOpeningRoundBrace) {··· var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } |
| ✓ Negative was executed (else) | }··· if (beforeOpeningCurlyBrace) { |
| Branch IfStatement | |
|---|---|
| ✗ Positive was not executed (if) | if (node.async && functionToken.value === 'async') {··· functionToken = file.getNextToken(functionToken); } |
| ✓ Negative was executed (else) | }··· // if generator, set token to be * instead |
| Branch LogicalExpression | |
| ✗ Was not returned | if (node.async && functionToken.value === 'async') { |
| ✓ Was returned | if (node.async && functionToken.value === 'async') { |
| Branch IfStatement | |
|---|---|
| ✗ Positive was not executed (if) | if (node.generator && functionToken.value === 'function') {··· functionToken = file.getNextToken(functionToken); } |
| ✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
| Branch LogicalExpression | |
| ✗ Was not returned | if (node.generator && functionToken.value === 'function') { |
| ✓ Was returned | if (node.generator && functionToken.value === 'function') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (beforeOpeningCurlyBrace) {··· var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_618) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_619) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_620) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpacesInCallExpression'; }, |
| Function (anonymous_621) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType(['CallExpression', 'NewExpression'], function(node) { function doesTokenBelongToNode(token, node) { return token.range[1] <= node.range[1]; } var lastCalleeToken = file.getLastNodeToken(node.callee); var roundBraceToken = file.findNextToken(lastCalleeToken, 'Punctuator', '('); // CallExpressions can't have missing parens, otherwise they're identifiers if (node.type === 'NewExpression') { if (roundBraceToken === null || !doesTokenBelongToNode(roundBraceToken, node)) { return; } } errors.assert.noWhitespaceBetween({ token: file.getPrevToken(roundBraceToken), nextToken: roundBraceToken, message: 'Illegal space before opening round brace' }); }); } |
| Function (anonymous_622) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['CallExpression', 'NewExpression'], function(node) {··· function doesTokenBelongToNode(token, node) { return token.range[1] <= node.range[1]; } var lastCalleeToken = file.getLastNodeToken(node.callee); var roundBraceToken = file.findNextToken(lastCalleeToken, 'Punctuator', '('); // CallExpressions can't have missing parens, otherwise they're identifiers if (node.type === 'NewExpression') { if (roundBraceToken === null || !doesTokenBelongToNode(roundBraceToken, node)) { return; } } errors.assert.noWhitespaceBetween({ token: file.getPrevToken(roundBraceToken), nextToken: roundBraceToken, message: 'Illegal space before opening round brace' }); }); |
| Function doesTokenBelongToNode | |
|---|---|
| ✓ Was called | function doesTokenBelongToNode(token, node) {··· return token.range[1] <= node.range[1]; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.type === 'NewExpression') {··· if (roundBraceToken === null || !doesTokenBelongToNode(roundBraceToken, node)) { return; } } |
| ✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (roundBraceToken === null || !doesTokenBelongToNode(roundBraceToken, node)) {··· return; } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | if (roundBraceToken === null || !doesTokenBelongToNode(roundBraceToken, node)) { |
| ✓ Was returned | if (roundBraceToken === null || !doesTokenBelongToNode(roundBraceToken, node)) { |
| Function (anonymous_624) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_625) | |
|---|---|
| ✓ Was called | configure: function(options) {··· var validProperties = [ 'afterTest', 'beforeConsequent', 'afterConsequent', 'beforeAlternate' ]; var optionName = this.getOptionName(); if (options === true) { options = { 'afterTest': true, 'beforeConsequent': true, 'afterConsequent': true, 'beforeAlternate': true }; } assert( typeof options === 'object', optionName + ' option requires a true value or an object' ); var isProperlyConfigured = validProperties.some(function(key) { var isPresent = key in options; if (isPresent) { assert( options[key] === true, optionName + '.' + key + ' property requires true value or should be removed' ); } return isPresent; }); assert( isProperlyConfigured, optionName + ' must have at least 1 of the following properties: ' + validProperties.join(', ') ); validProperties.forEach(function(property) { this['_' + property] = Boolean(options[property]); }.bind(this)); }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options === true) {··· options = { 'afterTest': true, 'beforeConsequent': true, 'afterConsequent': true, 'beforeAlternate': true }; } |
| ✓ Negative was executed (else) | }··· assert( |
| Function (anonymous_626) | |
|---|---|
| ✓ Was called | var isProperlyConfigured = validProperties.some(function(key) {··· var isPresent = key in options; if (isPresent) { assert( options[key] === true, optionName + '.' + key + ' property requires true value or should be removed' ); } return isPresent; }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isPresent) {··· assert( options[key] === true, optionName + '.' + key + ' property requires true value or should be removed' ); } |
| ✓ Negative was executed (else) | }··· return isPresent; |
| Function (anonymous_627) | |
|---|---|
| ✓ Was called | validProperties.forEach(function(property) {··· this['_' + property] = Boolean(options[property]); }.bind(this)); |
| Function (anonymous_628) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpacesInConditionalExpression'; }, |
| Function (anonymous_629) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType(['ConditionalExpression'], function(node) { var test = node.test; var consequent = node.consequent; var consequentToken = file.getFirstNodeToken(consequent); var alternate = node.alternate; var alternateToken = file.getFirstNodeToken(alternate); var questionMarkToken = file.findPrevOperatorToken(consequentToken, '?'); var colonToken = file.findPrevOperatorToken(alternateToken, ':'); var token; if (this._afterTest && test.loc.end.line === questionMarkToken.loc.start.line) { token = file.getPrevToken(questionMarkToken); errors.assert.noWhitespaceBetween({ token: token, nextToken: questionMarkToken, message: 'Illegal space after test' }); } if (this._beforeConsequent && consequent.loc.end.line === questionMarkToken.loc.start.line) { token = file.getNextToken(questionMarkToken); errors.assert.noWhitespaceBetween({ token: questionMarkToken, nextToken: token, message: 'Illegal space before consequent' }); } if (this._afterConsequent && consequent.loc.end.line === colonToken.loc.start.line) { token = file.getPrevToken(colonToken); errors.assert.noWhitespaceBetween({ token: token, nextToken: colonToken, message: 'Illegal space after consequent' }); } if (this._beforeAlternate && alternate.loc.end.line === colonToken.loc.start.line) { token = file.getNextToken(colonToken); errors.assert.noWhitespaceBetween({ token: colonToken, nextToken: token, message: 'Illegal space before alternate' }); } }.bind(this)); } |
| Function (anonymous_630) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['ConditionalExpression'], function(node) {··· var test = node.test; var consequent = node.consequent; var consequentToken = file.getFirstNodeToken(consequent); var alternate = node.alternate; var alternateToken = file.getFirstNodeToken(alternate); var questionMarkToken = file.findPrevOperatorToken(consequentToken, '?'); var colonToken = file.findPrevOperatorToken(alternateToken, ':'); var token; if (this._afterTest && test.loc.end.line === questionMarkToken.loc.start.line) { token = file.getPrevToken(questionMarkToken); errors.assert.noWhitespaceBetween({ token: token, nextToken: questionMarkToken, message: 'Illegal space after test' }); } if (this._beforeConsequent && consequent.loc.end.line === questionMarkToken.loc.start.line) { token = file.getNextToken(questionMarkToken); errors.assert.noWhitespaceBetween({ token: questionMarkToken, nextToken: token, message: 'Illegal space before consequent' }); } if (this._afterConsequent && consequent.loc.end.line === colonToken.loc.start.line) { token = file.getPrevToken(colonToken); errors.assert.noWhitespaceBetween({ token: token, nextToken: colonToken, message: 'Illegal space after consequent' }); } if (this._beforeAlternate && alternate.loc.end.line === colonToken.loc.start.line) { token = file.getNextToken(colonToken); errors.assert.noWhitespaceBetween({ token: colonToken, nextToken: token, message: 'Illegal space before alternate' }); } }.bind(this)); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._afterTest && test.loc.end.line === questionMarkToken.loc.start.line) {··· token = file.getPrevToken(questionMarkToken); errors.assert.noWhitespaceBetween({ token: token, nextToken: questionMarkToken, message: 'Illegal space after test' }); } |
| ✓ Negative was executed (else) | }··· if (this._beforeConsequent && consequent.loc.end.line === questionMarkToken.loc.start.line) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (this._afterTest && test.loc.end.line === questionMarkToken.loc.start.line) { |
| ✓ Was returned | if (this._afterTest && test.loc.end.line === questionMarkToken.loc.start.line) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._beforeConsequent && consequent.loc.end.line === questionMarkToken.loc.start.line) {··· token = file.getNextToken(questionMarkToken); errors.assert.noWhitespaceBetween({ token: questionMarkToken, nextToken: token, message: 'Illegal space before consequent' }); } |
| ✓ Negative was executed (else) | }··· if (this._afterConsequent && consequent.loc.end.line === colonToken.loc.start.line) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (this._beforeConsequent && consequent.loc.end.line === questionMarkToken.loc.start.line) { |
| ✓ Was returned | if (this._beforeConsequent && consequent.loc.end.line === questionMarkToken.loc.start.line) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._afterConsequent && consequent.loc.end.line === colonToken.loc.start.line) {··· token = file.getPrevToken(colonToken); errors.assert.noWhitespaceBetween({ token: token, nextToken: colonToken, message: 'Illegal space after consequent' }); } |
| ✓ Negative was executed (else) | }··· if (this._beforeAlternate && alternate.loc.end.line === colonToken.loc.start.line) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (this._afterConsequent && consequent.loc.end.line === colonToken.loc.start.line) { |
| ✓ Was returned | if (this._afterConsequent && consequent.loc.end.line === colonToken.loc.start.line) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._beforeAlternate && alternate.loc.end.line === colonToken.loc.start.line) {··· token = file.getNextToken(colonToken); errors.assert.noWhitespaceBetween({ token: colonToken, nextToken: token, message: 'Illegal space before alternate' }); } |
| ✓ Negative was executed (else) | }··· }.bind(this)); |
| Branch LogicalExpression | |
| ✓ Was returned | if (this._beforeAlternate && alternate.loc.end.line === colonToken.loc.start.line) { |
| ✓ Was returned | if (this._beforeAlternate && alternate.loc.end.line === colonToken.loc.start.line) { |
| Function (anonymous_631) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_632) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_633) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpacesInForStatement'; }, |
| Function (anonymous_634) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('ForStatement', function(node) { if (node.test) { var testToken = file.getFirstNodeToken(node.test); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(testToken), nextToken: testToken, message: 'Space found after semicolon' }); } if (node.update) { var updateToken = file.getFirstNodeToken(node.update); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(updateToken), nextToken: updateToken, message: 'Space found after semicolon' }); } }); } |
| Function (anonymous_635) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('ForStatement', function(node) {··· if (node.test) { var testToken = file.getFirstNodeToken(node.test); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(testToken), nextToken: testToken, message: 'Space found after semicolon' }); } if (node.update) { var updateToken = file.getFirstNodeToken(node.update); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(updateToken), nextToken: updateToken, message: 'Space found after semicolon' }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.test) {··· var testToken = file.getFirstNodeToken(node.test); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(testToken), nextToken: testToken, message: 'Space found after semicolon' }); } |
| ✓ Negative was executed (else) | }··· if (node.update) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.update) {··· var updateToken = file.getFirstNodeToken(node.update); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(updateToken), nextToken: updateToken, message: 'Space found after semicolon' }); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_636) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_637) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( typeof options === 'object', this.getOptionName() + ' option must be the object' ); if ('beforeOpeningRoundBrace' in options) { assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } if ('beforeOpeningCurlyBrace' in options) { assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } assert( options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, this.getOptionName() + ' must have beforeOpeningCurlyBrace or beforeOpeningRoundBrace property' ); this._beforeOpeningRoundBrace = Boolean(options.beforeOpeningRoundBrace); this._beforeOpeningCurlyBrace = Boolean(options.beforeOpeningCurlyBrace); }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('beforeOpeningRoundBrace' in options) {··· assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } |
| ✓ Negative was executed (else) | }··· if ('beforeOpeningCurlyBrace' in options) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('beforeOpeningCurlyBrace' in options) {··· assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } |
| ✓ Negative was executed (else) | }··· assert( |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
| ✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
| Function (anonymous_638) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpacesInFunctionDeclaration'; }, |
| Function (anonymous_639) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var beforeOpeningRoundBrace = this._beforeOpeningRoundBrace; var beforeOpeningCurlyBrace = this._beforeOpeningCurlyBrace; file.iterateNodesByType(['FunctionDeclaration'], function(node) { // Exception for `export default function` #1376 if (!node.id) { return; } if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(node.id); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } }); } |
| Function (anonymous_640) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['FunctionDeclaration'], function(node) {··· // Exception for `export default function` #1376 if (!node.id) { return; } if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(node.id); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!node.id) {··· return; } |
| ✓ Negative was executed (else) | }··· if (beforeOpeningRoundBrace) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (beforeOpeningRoundBrace) {··· var functionToken = file.getFirstNodeToken(node.id); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } |
| ✓ Negative was executed (else) | }··· if (beforeOpeningCurlyBrace) { |
| Branch IfStatement | |
|---|---|
| ✗ Positive was not executed (if) | if (node.async && functionToken.value === 'async') {··· functionToken = file.getNextToken(functionToken); } |
| ✓ Negative was executed (else) | }··· // if generator, set token to be * instead |
| Branch LogicalExpression | |
| ✗ Was not returned | if (node.async && functionToken.value === 'async') { |
| ✓ Was returned | if (node.async && functionToken.value === 'async') { |
| Branch IfStatement | |
|---|---|
| ✗ Positive was not executed (if) | if (node.generator && functionToken.value === 'function') {··· functionToken = file.getNextToken(functionToken); } |
| ✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
| Branch LogicalExpression | |
| ✗ Was not returned | if (node.generator && functionToken.value === 'function') { |
| ✓ Was returned | if (node.generator && functionToken.value === 'function') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (beforeOpeningCurlyBrace) {··· var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_641) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_642) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( typeof options === 'object', this.getOptionName() + ' option must be the object' ); if ('beforeOpeningRoundBrace' in options) { assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } if ('beforeOpeningCurlyBrace' in options) { assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } assert( options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, this.getOptionName() + ' must have beforeOpeningCurlyBrace or beforeOpeningRoundBrace property' ); this._beforeOpeningRoundBrace = Boolean(options.beforeOpeningRoundBrace); this._beforeOpeningCurlyBrace = Boolean(options.beforeOpeningCurlyBrace); }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('beforeOpeningRoundBrace' in options) {··· assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } |
| ✓ Negative was executed (else) | }··· if ('beforeOpeningCurlyBrace' in options) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('beforeOpeningCurlyBrace' in options) {··· assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } |
| ✓ Negative was executed (else) | }··· assert( |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
| ✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
| Function (anonymous_643) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpacesInFunctionExpression'; }, |
| Function (anonymous_644) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var beforeOpeningRoundBrace = this._beforeOpeningRoundBrace; var beforeOpeningCurlyBrace = this._beforeOpeningCurlyBrace; file.iterateNodesByType('FunctionExpression', function(node) { // for a named function, use node.id var functionNode = node.id || node; var parent = node.parentNode; // Ignore syntactic sugar for getters and setters. if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { return; } // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { functionNode = parent.key; } if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } }); } |
| Function (anonymous_645) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('FunctionExpression', function(node) {··· // for a named function, use node.id var functionNode = node.id || node; var parent = node.parentNode; // Ignore syntactic sugar for getters and setters. if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { return; } // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { functionNode = parent.key; } if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } }); |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | var functionNode = node.id || node; |
| ✓ Was returned | var functionNode = node.id || node; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) {··· return; } |
| ✓ Negative was executed (else) | }··· // shorthand or constructor methods |
| Branch LogicalExpression | |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (parent.method || parent.type === 'MethodDefinition') {··· functionNode = parent.key; } |
| ✓ Negative was executed (else) | }··· if (beforeOpeningRoundBrace) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (parent.method || parent.type === 'MethodDefinition') { |
| ✓ Was returned | if (parent.method || parent.type === 'MethodDefinition') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (beforeOpeningRoundBrace) {··· var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } |
| ✓ Negative was executed (else) | }··· if (beforeOpeningCurlyBrace) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.async && functionToken.value === 'async') {··· functionToken = file.getNextToken(functionToken); } |
| ✓ Negative was executed (else) | }··· // if generator, set token to be * instead |
| Branch LogicalExpression | |
| ✓ Was returned | if (node.async && functionToken.value === 'async') { |
| ✓ Was returned | if (node.async && functionToken.value === 'async') { |
| Branch IfStatement | |
|---|---|
| ✗ Positive was not executed (if) | if (node.generator && functionToken.value === 'function') {··· functionToken = file.getNextToken(functionToken); } |
| ✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
| Branch LogicalExpression | |
| ✗ Was not returned | if (node.generator && functionToken.value === 'function') { |
| ✓ Was returned | if (node.generator && functionToken.value === 'function') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (beforeOpeningCurlyBrace) {··· var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_646) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_647) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( typeof options === 'object', this.getOptionName() + ' option must be the object' ); if ('beforeOpeningRoundBrace' in options) { assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } if ('beforeOpeningCurlyBrace' in options) { assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } assert( options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, this.getOptionName() + ' must have beforeOpeningCurlyBrace or beforeOpeningRoundBrace property' ); this._beforeOpeningRoundBrace = Boolean(options.beforeOpeningRoundBrace); this._beforeOpeningCurlyBrace = Boolean(options.beforeOpeningCurlyBrace); }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('beforeOpeningRoundBrace' in options) {··· assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } |
| ✓ Negative was executed (else) | }··· if ('beforeOpeningCurlyBrace' in options) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('beforeOpeningCurlyBrace' in options) {··· assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } |
| ✓ Negative was executed (else) | }··· assert( |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
| ✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
| Function (anonymous_648) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpacesInFunction'; }, |
| Function (anonymous_649) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var beforeOpeningRoundBrace = this._beforeOpeningRoundBrace; var beforeOpeningCurlyBrace = this._beforeOpeningCurlyBrace; file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) { // for a named function, use node.id var functionNode = node.id || node; var parent = node.parentNode; // Ignore syntactic sugar for getters and setters. if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { return; } // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { functionNode = parent.key; } if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } }); } |
| Function (anonymous_650) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) {··· // for a named function, use node.id var functionNode = node.id || node; var parent = node.parentNode; // Ignore syntactic sugar for getters and setters. if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { return; } // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { functionNode = parent.key; } if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } }); |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | var functionNode = node.id || node; |
| ✓ Was returned | var functionNode = node.id || node; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) {··· return; } |
| ✓ Negative was executed (else) | }··· // shorthand or constructor methods |
| Branch LogicalExpression | |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (parent.method || parent.type === 'MethodDefinition') {··· functionNode = parent.key; } |
| ✓ Negative was executed (else) | }··· if (beforeOpeningRoundBrace) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (parent.method || parent.type === 'MethodDefinition') { |
| ✓ Was returned | if (parent.method || parent.type === 'MethodDefinition') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (beforeOpeningRoundBrace) {··· var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } |
| ✓ Negative was executed (else) | }··· if (beforeOpeningCurlyBrace) { |
| Branch IfStatement | |
|---|---|
| ✗ Positive was not executed (if) | if (node.async && functionToken.value === 'async') {··· functionToken = file.getNextToken(functionToken); } |
| ✓ Negative was executed (else) | }··· // if generator, set token to be * instead |
| Branch LogicalExpression | |
| ✗ Was not returned | if (node.async && functionToken.value === 'async') { |
| ✓ Was returned | if (node.async && functionToken.value === 'async') { |
| Branch IfStatement | |
|---|---|
| ✗ Positive was not executed (if) | if (node.generator && functionToken.value === 'function') {··· functionToken = file.getNextToken(functionToken); } |
| ✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
| Branch LogicalExpression | |
| ✗ Was not returned | if (node.generator && functionToken.value === 'function') { |
| ✓ Was returned | if (node.generator && functionToken.value === 'function') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (beforeOpeningCurlyBrace) {··· var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_651) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_652) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( typeof options === 'object', this.getOptionName() + ' option must be an object' ); if ('beforeStar' in options) { assert( options.beforeStar === true, this.getOptionName() + '.beforeStar ' + 'property requires true value or should be removed' ); } if ('afterStar' in options) { assert( options.afterStar === true, this.getOptionName() + '.afterStar ' + 'property requires true value or should be removed' ); } assert( options.beforeStar || options.afterStar, this.getOptionName() + ' must have beforeStar or afterStar property' ); this._beforeStar = options.beforeStar; this._afterStar = options.afterStar; }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('beforeStar' in options) {··· assert( options.beforeStar === true, this.getOptionName() + '.beforeStar ' + 'property requires true value or should be removed' ); } |
| ✓ Negative was executed (else) | }··· if ('afterStar' in options) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('afterStar' in options) {··· assert( options.afterStar === true, this.getOptionName() + '.afterStar ' + 'property requires true value or should be removed' ); } |
| ✓ Negative was executed (else) | }··· assert( |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options.beforeStar || options.afterStar, |
| ✓ Was returned | options.beforeStar || options.afterStar, |
| Function (anonymous_653) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpacesInGenerator'; }, |
| Function (anonymous_654) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var beforeStar = this._beforeStar; var afterStar = this._afterStar; file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) { if (!node.generator) { return; } var parent = node.parentNode; var shorthand = false; // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { shorthand = true; node = parent.key; } var currentToken = file.getFirstNodeToken(node); if (node.async && currentToken.value === 'async') { currentToken = file.getNextToken(currentToken); } if (beforeStar && !shorthand) { // currentToken assigned outside of function errors.assert.noWhitespaceBetween({ token: currentToken, nextToken: file.getNextToken(currentToken), message: 'Illegal space before star' }); } if (afterStar) { if (shorthand) { currentToken = file.getPrevToken(currentToken); } else { // currentToken reassigned for star token currentToken = file.getNextToken(currentToken); } errors.assert.noWhitespaceBetween({ token: currentToken, nextToken: file.getNextToken(currentToken), message: 'Illegal space after star' }); } }); } |
| Function (anonymous_655) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) {··· if (!node.generator) { return; } var parent = node.parentNode; var shorthand = false; // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { shorthand = true; node = parent.key; } var currentToken = file.getFirstNodeToken(node); if (node.async && currentToken.value === 'async') { currentToken = file.getNextToken(currentToken); } if (beforeStar && !shorthand) { // currentToken assigned outside of function errors.assert.noWhitespaceBetween({ token: currentToken, nextToken: file.getNextToken(currentToken), message: 'Illegal space before star' }); } if (afterStar) { if (shorthand) { currentToken = file.getPrevToken(currentToken); } else { // currentToken reassigned for star token currentToken = file.getNextToken(currentToken); } errors.assert.noWhitespaceBetween({ token: currentToken, nextToken: file.getNextToken(currentToken), message: 'Illegal space after star' }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!node.generator) {··· return; } |
| ✓ Negative was executed (else) | }··· var parent = node.parentNode; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (parent.method || parent.type === 'MethodDefinition') {··· shorthand = true; node = parent.key; } |
| ✓ Negative was executed (else) | }··· var currentToken = file.getFirstNodeToken(node); |
| Branch LogicalExpression | |
| ✓ Was returned | if (parent.method || parent.type === 'MethodDefinition') { |
| ✓ Was returned | if (parent.method || parent.type === 'MethodDefinition') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.async && currentToken.value === 'async') {··· currentToken = file.getNextToken(currentToken); } |
| ✓ Negative was executed (else) | }··· if (beforeStar && !shorthand) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (node.async && currentToken.value === 'async') { |
| ✓ Was returned | if (node.async && currentToken.value === 'async') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (beforeStar && !shorthand) {··· // currentToken assigned outside of function errors.assert.noWhitespaceBetween({ token: currentToken, nextToken: file.getNextToken(currentToken), message: 'Illegal space before star' }); } |
| ✓ Negative was executed (else) | }··· if (afterStar) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (beforeStar && !shorthand) { |
| ✓ Was returned | if (beforeStar && !shorthand) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (afterStar) {··· if (shorthand) { currentToken = file.getPrevToken(currentToken); } else { // currentToken reassigned for star token currentToken = file.getNextToken(currentToken); } errors.assert.noWhitespaceBetween({ token: currentToken, nextToken: file.getNextToken(currentToken), message: 'Illegal space after star' }); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (shorthand) {··· currentToken = file.getPrevToken(currentToken); } else { |
| ✓ Negative was executed (else) | } else {··· // currentToken reassigned for star token currentToken = file.getNextToken(currentToken); } |
| Function (anonymous_656) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_657) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( typeof options === 'object', this.getOptionName() + ' option must be the object' ); if ('beforeOpeningRoundBrace' in options) { assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } if ('beforeOpeningCurlyBrace' in options) { assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } assert( options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, this.getOptionName() + ' must have beforeOpeningCurlyBrace ' + 'or beforeOpeningRoundBrace property' ); this._beforeOpeningRoundBrace = Boolean(options.beforeOpeningRoundBrace); this._beforeOpeningCurlyBrace = Boolean(options.beforeOpeningCurlyBrace); }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('beforeOpeningRoundBrace' in options) {··· assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } |
| ✓ Negative was executed (else) | }··· if ('beforeOpeningCurlyBrace' in options) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('beforeOpeningCurlyBrace' in options) {··· assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } |
| ✓ Negative was executed (else) | }··· assert( |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
| ✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
| Function (anonymous_658) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpacesInNamedFunctionExpression'; }, |
| Function (anonymous_659) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var beforeOpeningRoundBrace = this._beforeOpeningRoundBrace; var beforeOpeningCurlyBrace = this._beforeOpeningCurlyBrace; file.iterateNodesByType(['FunctionExpression'], function(node) { var functionNode = node.id; var parent = node.parentNode; // Ignore syntactic sugar for getters and setters. if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { return; } // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { functionNode = parent.key; } // named function expressions only if (node.id) { if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } } }); } |
| Function (anonymous_660) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['FunctionExpression'], function(node) {··· var functionNode = node.id; var parent = node.parentNode; // Ignore syntactic sugar for getters and setters. if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { return; } // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { functionNode = parent.key; } // named function expressions only if (node.id) { if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) {··· return; } |
| ✓ Negative was executed (else) | }··· // shorthand or constructor methods |
| Branch LogicalExpression | |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (parent.method || parent.type === 'MethodDefinition') {··· functionNode = parent.key; } |
| ✓ Negative was executed (else) | }··· // named function expressions only |
| Branch LogicalExpression | |
| ✓ Was returned | if (parent.method || parent.type === 'MethodDefinition') { |
| ✓ Was returned | if (parent.method || parent.type === 'MethodDefinition') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.id) {··· if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } } |
| ✓ Negative was executed (else) | }··· }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (beforeOpeningRoundBrace) {··· var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } |
| ✓ Negative was executed (else) | }··· if (beforeOpeningCurlyBrace) { |
| Branch IfStatement | |
|---|---|
| ✗ Positive was not executed (if) | if (node.async && functionToken.value === 'async') {··· functionToken = file.getNextToken(functionToken); } |
| ✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
| Branch LogicalExpression | |
| ✗ Was not returned | if (node.async && functionToken.value === 'async') { |
| ✓ Was returned | if (node.async && functionToken.value === 'async') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (beforeOpeningCurlyBrace) {··· var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_661) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_662) | |
|---|---|
| ✓ Was called | configure: function(value) {··· var mode; var modes = { 'all': true, 'nested': true }; var isObject = typeof value === 'object'; var error = this.getOptionName() + ' rule' + ' requires string value "all" or "nested" or object'; if (typeof value === 'string' || value === true) { assert(modes[value === true ? 'all' : value], error); } else if (isObject) { assert('allExcept' in value, error); } else { assert(false, error); } this._exceptions = {}; if (isObject) { (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } else { mode = value; } if (mode === 'nested') { this._exceptions['['] = this._exceptions[']'] = true; } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof value === 'string' || value === true) {··· assert(modes[value === true ? 'all' : value], error); } else if (isObject) { |
| ✓ Negative was executed (else) | } else if (isObject) {··· assert('allExcept' in value, error); } else { assert(false, error); } |
| Branch LogicalExpression | |
| ✓ Was returned | if (typeof value === 'string' || value === true) { |
| ✓ Was returned | if (typeof value === 'string' || value === true) { |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | assert(modes[value === true ? 'all' : value], error); |
| ✓ Negative was returned (: ...) | assert(modes[value === true ? 'all' : value], error); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (isObject) {··· assert('allExcept' in value, error); } else { |
| ✓ Negative was executed (else) | } else {··· assert(false, error); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isObject) {··· (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } else { |
| ✓ Negative was executed (else) | } else {··· mode = value; } |
| Function (anonymous_663) | |
|---|---|
| ✓ Was called | (value.allExcept || []).forEach(function(value) {··· this._exceptions[value] = true; }, this); |
| Branch LogicalExpression | |
| ✓ Was returned | (value.allExcept || []).forEach(function(value) { |
| ✓ Was returned | (value.allExcept || []).forEach(function(value) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (mode === 'nested') {··· this._exceptions['['] = this._exceptions[']'] = true; } |
| ✓ Negative was executed (else) | }··· }, |
| Function (anonymous_664) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpacesInsideArrayBrackets'; }, |
| Function (anonymous_665) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var exceptions = this._exceptions; file.iterateNodesByType('ArrayExpression', function(node) { var openBracket = file.getFirstNodeToken(node); var afterOpen = file.getNextToken(openBracket, {includeComments: true}); var closeBracket = file.getLastNodeToken(node); var beforeClose = file.getPrevToken(closeBracket, {includeComments: true}); // Skip for empty array brackets if (afterOpen.value === ']') { return; } if (!(afterOpen.value in exceptions)) { errors.assert.noWhitespaceBetween({ token: openBracket, nextToken: afterOpen, message: 'Illegal space after opening bracket' }); } if (!(beforeClose.value in exceptions)) { errors.assert.noWhitespaceBetween({ token: beforeClose, nextToken: closeBracket, message: 'Illegal space before closing bracket' }); } }); } |
| Function (anonymous_666) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('ArrayExpression', function(node) {··· var openBracket = file.getFirstNodeToken(node); var afterOpen = file.getNextToken(openBracket, {includeComments: true}); var closeBracket = file.getLastNodeToken(node); var beforeClose = file.getPrevToken(closeBracket, {includeComments: true}); // Skip for empty array brackets if (afterOpen.value === ']') { return; } if (!(afterOpen.value in exceptions)) { errors.assert.noWhitespaceBetween({ token: openBracket, nextToken: afterOpen, message: 'Illegal space after opening bracket' }); } if (!(beforeClose.value in exceptions)) { errors.assert.noWhitespaceBetween({ token: beforeClose, nextToken: closeBracket, message: 'Illegal space before closing bracket' }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (afterOpen.value === ']') {··· return; } |
| ✓ Negative was executed (else) | }··· if (!(afterOpen.value in exceptions)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!(afterOpen.value in exceptions)) {··· errors.assert.noWhitespaceBetween({ token: openBracket, nextToken: afterOpen, message: 'Illegal space after opening bracket' }); } |
| ✓ Negative was executed (else) | }··· if (!(beforeClose.value in exceptions)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!(beforeClose.value in exceptions)) {··· errors.assert.noWhitespaceBetween({ token: beforeClose, nextToken: closeBracket, message: 'Illegal space before closing bracket' }); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_667) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_668) | |
|---|---|
| ✓ Was called | configure: function(value) {··· var isObject = typeof value === 'object'; var error = this.getOptionName() + ' rule requires string value true or object'; if (isObject) { assert('allExcept' in value, error); } else { assert(value === true, error); } this._exceptions = {}; if (isObject) { (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isObject) {··· assert('allExcept' in value, error); } else { |
| ✓ Negative was executed (else) | } else {··· assert(value === true, error); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isObject) {··· (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } |
| ✓ Negative was executed (else) | }··· }, |
| Function (anonymous_669) | |
|---|---|
| ✓ Was called | (value.allExcept || []).forEach(function(value) {··· this._exceptions[value] = true; }, this); |
| Branch LogicalExpression | |
| ✓ Was returned | (value.allExcept || []).forEach(function(value) { |
| ✓ Was returned | (value.allExcept || []).forEach(function(value) { |
| Function (anonymous_670) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpacesInsideBrackets'; }, |
| Function (anonymous_671) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var exceptions = this._exceptions; file.iterateTokenByValue('[', function(token) { var nextToken = file.getNextToken(token, { includeComments: true }); var value = nextToken.value; if (value in exceptions) { return; } // Skip for empty array brackets if (value === ']') { return; } errors.assert.noWhitespaceBetween({ token: token, nextToken: nextToken, message: 'Illegal space after opening bracket' }); }); file.iterateTokenByValue(']', function(token) { var prevToken = file.getPrevToken(token, { includeComments: true }); var value = prevToken.value; if (value in exceptions) { return; } // Skip for empty array brackets if (value === '[') { return; } errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: token, message: 'Illegal space before closing bracket' }); }); } |
| Function (anonymous_672) | |
|---|---|
| ✓ Was called | file.iterateTokenByValue('[', function(token) {··· var nextToken = file.getNextToken(token, { includeComments: true }); var value = nextToken.value; if (value in exceptions) { return; } // Skip for empty array brackets if (value === ']') { return; } errors.assert.noWhitespaceBetween({ token: token, nextToken: nextToken, message: 'Illegal space after opening bracket' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value in exceptions) {··· return; } |
| ✓ Negative was executed (else) | }··· // Skip for empty array brackets |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value === ']') {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
| Function (anonymous_673) | |
|---|---|
| ✓ Was called | file.iterateTokenByValue(']', function(token) {··· var prevToken = file.getPrevToken(token, { includeComments: true }); var value = prevToken.value; if (value in exceptions) { return; } // Skip for empty array brackets if (value === '[') { return; } errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: token, message: 'Illegal space before closing bracket' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value in exceptions) {··· return; } |
| ✓ Negative was executed (else) | }··· // Skip for empty array brackets |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value === '[') {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
| Function (anonymous_674) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_675) | |
|---|---|
| ✓ Was called | configure: function(value) {··· var mode; var modes = { 'all': true, 'nested': true }; var isObject = typeof value === 'object'; var error = this.getOptionName() + ' rule' + ' requires string "all" or "nested", true value or object'; if (typeof value === 'string' || value === true) { assert(modes[value === true ? 'all' : value], error); } else if (isObject) { assert('allExcept' in value, error); } else { assert(false, error); } this._exceptions = {}; if (isObject) { (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } else { mode = value; } if (mode === 'nested') { this._exceptions['}'] = true; } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof value === 'string' || value === true) {··· assert(modes[value === true ? 'all' : value], error); } else if (isObject) { |
| ✓ Negative was executed (else) | } else if (isObject) {··· assert('allExcept' in value, error); } else { assert(false, error); } |
| Branch LogicalExpression | |
| ✓ Was returned | if (typeof value === 'string' || value === true) { |
| ✓ Was returned | if (typeof value === 'string' || value === true) { |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | assert(modes[value === true ? 'all' : value], error); |
| ✓ Negative was returned (: ...) | assert(modes[value === true ? 'all' : value], error); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (isObject) {··· assert('allExcept' in value, error); } else { |
| ✓ Negative was executed (else) | } else {··· assert(false, error); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isObject) {··· (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } else { |
| ✓ Negative was executed (else) | } else {··· mode = value; } |
| Function (anonymous_676) | |
|---|---|
| ✓ Was called | (value.allExcept || []).forEach(function(value) {··· this._exceptions[value] = true; }, this); |
| Branch LogicalExpression | |
| ✓ Was returned | (value.allExcept || []).forEach(function(value) { |
| ✓ Was returned | (value.allExcept || []).forEach(function(value) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (mode === 'nested') {··· this._exceptions['}'] = true; } |
| ✓ Negative was executed (else) | }··· }, |
| Function (anonymous_677) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpacesInsideObjectBrackets'; }, |
| Function (anonymous_678) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var exceptions = this._exceptions; file.iterateNodesByType(['ObjectExpression', 'ObjectPattern'], function(node) { var openingBracket = file.getFirstNodeToken(node); var nextToken = file.getNextToken(openingBracket); errors.assert.noWhitespaceBetween({ token: openingBracket, nextToken: nextToken, message: 'Illegal space after opening curly brace' }); var closingBracket = file.getLastNodeToken(node); var prevToken = file.getPrevToken(closingBracket); if (prevToken.value in exceptions) { return; } errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: closingBracket, message: 'Illegal space before closing curly brace' }); }); } |
| Function (anonymous_679) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['ObjectExpression', 'ObjectPattern'], function(node) {··· var openingBracket = file.getFirstNodeToken(node); var nextToken = file.getNextToken(openingBracket); errors.assert.noWhitespaceBetween({ token: openingBracket, nextToken: nextToken, message: 'Illegal space after opening curly brace' }); var closingBracket = file.getLastNodeToken(node); var prevToken = file.getPrevToken(closingBracket); if (prevToken.value in exceptions) { return; } errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: closingBracket, message: 'Illegal space before closing curly brace' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (prevToken.value in exceptions) {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
| Function (anonymous_680) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_681) | |
|---|---|
| ✓ Was called | configure: function(option) {··· var isObject = typeof option === 'object'; var error = this.getOptionName() + ' option requires' + ' true or object value with "only" properties '; // backcompat for 1.10: {all: true} #1027 if (isObject && option.all === true) { option = true; } if (typeof option === 'boolean') { assert(option === true, error); } else if (isObject) { assert('only' in option, error); } else { assert(false, error); } this._onlySingleQuote = false; this._onlyDoubleQuote = false; this._only = null; if (option.only) { this._only = {}; (option.only).forEach(function(value) { if (value === '\'') { this._onlySingleQuote = true; } if (value === '"') { this._onlyDoubleQuote = true; } this._only[value] = true; }, this); } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isObject && option.all === true) {··· option = true; } |
| ✓ Negative was executed (else) | }··· if (typeof option === 'boolean') { |
| Branch LogicalExpression | |
| ✓ Was returned | if (isObject && option.all === true) { |
| ✓ Was returned | if (isObject && option.all === true) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof option === 'boolean') {··· assert(option === true, error); } else if (isObject) { |
| ✓ Negative was executed (else) | } else if (isObject) {··· assert('only' in option, error); } else { assert(false, error); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (isObject) {··· assert('only' in option, error); } else { |
| ✓ Negative was executed (else) | } else {··· assert(false, error); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (option.only) {··· this._only = {}; (option.only).forEach(function(value) { if (value === '\'') { this._onlySingleQuote = true; } if (value === '"') { this._onlyDoubleQuote = true; } this._only[value] = true; }, this); } |
| ✓ Negative was executed (else) | }··· }, |
| Function (anonymous_682) | |
|---|---|
| ✓ Was called | (option.only).forEach(function(value) {··· if (value === '\'') { this._onlySingleQuote = true; } if (value === '"') { this._onlyDoubleQuote = true; } this._only[value] = true; }, this); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value === '\'') {··· this._onlySingleQuote = true; } |
| ✓ Negative was executed (else) | }··· if (value === '"') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value === '"') {··· this._onlyDoubleQuote = true; } |
| ✓ Negative was executed (else) | }··· this._only[value] = true; |
| Function (anonymous_683) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpacesInsideParentheses'; }, |
| Function (anonymous_684) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var only = this._only; var singleQuote = this._onlySingleQuote; var doubleQuote = this._onlyDoubleQuote; file.iterateTokenByValue('(', function(token) { var nextToken = file.getNextToken(token, {includeComments: true}); var value = nextToken.value; var shouldReturn = true; if (doubleQuote && nextToken.type === 'String' && value[0] === '"') { shouldReturn = false; } if (singleQuote && nextToken.type === 'String' && value[0] === '\'') { shouldReturn = false; } if (only && value in only) { shouldReturn = false; } if (!only) { shouldReturn = false; } if (shouldReturn) { return; } errors.assert.noWhitespaceBetween({ token: token, nextToken: nextToken, message: 'Illegal space after opening round bracket' }); }); file.iterateTokenByValue(')', function(token) { var prevToken = file.getPrevToken(token, {includeComments: true}); var value = prevToken.value; var shouldReturn = true; if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') { shouldReturn = false; } if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') { shouldReturn = false; } if (only) { if (value in only) { shouldReturn = false; } if ( value === ']' && file.getNodeByRange(prevToken.range[0]).type === 'MemberExpression' ) { shouldReturn = true; } } else { shouldReturn = false; } if (shouldReturn) { return; } errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: token, message: 'Illegal space before closing round bracket' }); }); } |
| Function (anonymous_685) | |
|---|---|
| ✓ Was called | file.iterateTokenByValue('(', function(token) {··· var nextToken = file.getNextToken(token, {includeComments: true}); var value = nextToken.value; var shouldReturn = true; if (doubleQuote && nextToken.type === 'String' && value[0] === '"') { shouldReturn = false; } if (singleQuote && nextToken.type === 'String' && value[0] === '\'') { shouldReturn = false; } if (only && value in only) { shouldReturn = false; } if (!only) { shouldReturn = false; } if (shouldReturn) { return; } errors.assert.noWhitespaceBetween({ token: token, nextToken: nextToken, message: 'Illegal space after opening round bracket' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (doubleQuote && nextToken.type === 'String' && value[0] === '"') {··· shouldReturn = false; } |
| ✓ Negative was executed (else) | }··· if (singleQuote && nextToken.type === 'String' && value[0] === '\'') { |
| Branch LogicalExpression | |
| ✓ Was returned | if (doubleQuote && nextToken.type === 'String' && value[0] === '"') { |
| ✓ Was returned | if (doubleQuote && nextToken.type === 'String' && value[0] === '"') { |
| Branch LogicalExpression | |
| ✓ Was returned | if (doubleQuote && nextToken.type === 'String' && value[0] === '"') { |
| ✓ Was returned | if (doubleQuote && nextToken.type === 'String' && value[0] === '"') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (singleQuote && nextToken.type === 'String' && value[0] === '\'') {··· shouldReturn = false; } |
| ✓ Negative was executed (else) | }··· if (only && value in only) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (singleQuote && nextToken.type === 'String' && value[0] === '\'') { |
| ✓ Was returned | if (singleQuote && nextToken.type === 'String' && value[0] === '\'') { |
| Branch LogicalExpression | |
| ✓ Was returned | if (singleQuote && nextToken.type === 'String' && value[0] === '\'') { |
| ✓ Was returned | if (singleQuote && nextToken.type === 'String' && value[0] === '\'') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (only && value in only) {··· shouldReturn = false; } |
| ✓ Negative was executed (else) | }··· if (!only) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (only && value in only) { |
| ✓ Was returned | if (only && value in only) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!only) {··· shouldReturn = false; } |
| ✓ Negative was executed (else) | }··· if (shouldReturn) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (shouldReturn) {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
| Function (anonymous_686) | |
|---|---|
| ✓ Was called | file.iterateTokenByValue(')', function(token) {··· var prevToken = file.getPrevToken(token, {includeComments: true}); var value = prevToken.value; var shouldReturn = true; if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') { shouldReturn = false; } if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') { shouldReturn = false; } if (only) { if (value in only) { shouldReturn = false; } if ( value === ']' && file.getNodeByRange(prevToken.range[0]).type === 'MemberExpression' ) { shouldReturn = true; } } else { shouldReturn = false; } if (shouldReturn) { return; } errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: token, message: 'Illegal space before closing round bracket' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') {··· shouldReturn = false; } |
| ✓ Negative was executed (else) | }··· if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') { |
| Branch LogicalExpression | |
| ✓ Was returned | if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') { |
| ✓ Was returned | if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') { |
| Branch LogicalExpression | |
| ✓ Was returned | if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') { |
| ✓ Was returned | if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') {··· shouldReturn = false; } |
| ✓ Negative was executed (else) | }··· if (only) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') { |
| ✓ Was returned | if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') { |
| Branch LogicalExpression | |
| ✓ Was returned | if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') { |
| ✓ Was returned | if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (only) {··· if (value in only) { shouldReturn = false; } if ( value === ']' && file.getNodeByRange(prevToken.range[0]).type === 'MemberExpression' ) { shouldReturn = true; } } else { |
| ✓ Negative was executed (else) | } else {··· shouldReturn = false; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value in only) {··· shouldReturn = false; } |
| ✓ Negative was executed (else) | }··· if ( |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | ) {··· shouldReturn = true; } |
| ✓ Negative was executed (else) | }··· } else { |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | file.getNodeByRange(prevToken.range[0]).type === 'MemberExpression' |
| ✓ Was returned | value === ']' && |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (shouldReturn) {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
| Function (anonymous_687) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_688) | |
|---|---|
| ✓ Was called | configure: function(value) {··· var isObject = typeof value === 'object'; var error = this.getOptionName() + ' rule requires string value true or object'; if (isObject) { assert('allExcept' in value, error); } else { assert(value === true, error); } this._exceptions = {}; if (isObject) { (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isObject) {··· assert('allExcept' in value, error); } else { |
| ✓ Negative was executed (else) | } else {··· assert(value === true, error); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isObject) {··· (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } |
| ✓ Negative was executed (else) | }··· }, |
| Function (anonymous_689) | |
|---|---|
| ✓ Was called | (value.allExcept || []).forEach(function(value) {··· this._exceptions[value] = true; }, this); |
| Branch LogicalExpression | |
| ✗ Was not returned | (value.allExcept || []).forEach(function(value) { |
| ✓ Was returned | (value.allExcept || []).forEach(function(value) { |
| Function (anonymous_690) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpacesInsideParenthesizedExpression'; }, |
| Function (anonymous_691) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var exceptions = this._exceptions; file.iterateTokenByValue('(', function(token) { var nextToken = file.getNextToken(token, {includeComments: true}); var value = nextToken.isComment ? nextToken.type === 'Block' ? '/*' : '//' : nextToken.value; // Skip empty parentheses and explicit exceptions if (value === ')' || value in exceptions) { return; } // Skip non-expression parentheses var type = TokenCategorizer.categorizeOpenParen(token, file); if (type !== 'ParenthesizedExpression') { return; } errors.assert.noWhitespaceBetween({ token: token, nextToken: nextToken, message: 'Illegal space after opening grouping parenthesis' }); }); file.iterateTokenByValue(')', function(token) { var prevToken = file.getPrevToken(token, {includeComments: true}); var value = prevToken.isComment ? prevToken.type === 'Block' ? '*/' : '' : prevToken.value; // Skip empty parentheses and explicit exceptions if (value === '(' || value in exceptions) { return; } // Skip non-expression parentheses var type = TokenCategorizer.categorizeCloseParen(token, file); if (type !== 'ParenthesizedExpression') { return; } errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: token, message: 'Illegal space before closing grouping parenthesis' }); }); } |
| Function (anonymous_692) | |
|---|---|
| ✓ Was called | file.iterateTokenByValue('(', function(token) {··· var nextToken = file.getNextToken(token, {includeComments: true}); var value = nextToken.isComment ? nextToken.type === 'Block' ? '/*' : '//' : nextToken.value; // Skip empty parentheses and explicit exceptions if (value === ')' || value in exceptions) { return; } // Skip non-expression parentheses var type = TokenCategorizer.categorizeOpenParen(token, file); if (type !== 'ParenthesizedExpression') { return; } errors.assert.noWhitespaceBetween({ token: token, nextToken: nextToken, message: 'Illegal space after opening grouping parenthesis' }); }); |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | nextToken.type === 'Block' ? '/*' : '//' : |
| ✓ Negative was returned (: ...) | nextToken.value; |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | nextToken.type === 'Block' ? '/*' : '//' : |
| ✓ Negative was returned (: ...) | nextToken.type === 'Block' ? '/*' : '//' : |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value === ')' || value in exceptions) {··· return; } |
| ✓ Negative was executed (else) | }··· // Skip non-expression parentheses |
| Branch LogicalExpression | |
| ✓ Was returned | if (value === ')' || value in exceptions) { |
| ✓ Was returned | if (value === ')' || value in exceptions) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (type !== 'ParenthesizedExpression') {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
| Function (anonymous_693) | |
|---|---|
| ✓ Was called | file.iterateTokenByValue(')', function(token) {··· var prevToken = file.getPrevToken(token, {includeComments: true}); var value = prevToken.isComment ? prevToken.type === 'Block' ? '*/' : '' : prevToken.value; // Skip empty parentheses and explicit exceptions if (value === '(' || value in exceptions) { return; } // Skip non-expression parentheses var type = TokenCategorizer.categorizeCloseParen(token, file); if (type !== 'ParenthesizedExpression') { return; } errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: token, message: 'Illegal space before closing grouping parenthesis' }); }); |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | prevToken.type === 'Block' ? '*/' : '' : |
| ✓ Negative was returned (: ...) | prevToken.value; |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | prevToken.type === 'Block' ? '*/' : '' : |
| ✓ Negative was returned (: ...) | prevToken.type === 'Block' ? '*/' : '' : |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value === '(' || value in exceptions) {··· return; } |
| ✓ Negative was executed (else) | }··· // Skip non-expression parentheses |
| Branch LogicalExpression | |
| ✓ Was returned | if (value === '(' || value in exceptions) { |
| ✓ Was returned | if (value === '(' || value in exceptions) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (type !== 'ParenthesizedExpression') {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
| Function (anonymous_694) | |
|---|---|
| ✓ Was called | exports.categorizeOpenParen = function(token, file) {··· assert(token.value === '(', 'Input token must be a parenthesis'); var node = file.getNodeByRange(token.range[0]); var nodeType = node.type; var prevToken = file.getPrevToken(token); // Outermost grouping parenthesis if (!prevToken) { return 'ParenthesizedExpression'; } // Part of a parentheses-bearing statement (if, with, while, switch, etc.) if (prevToken.type === 'Keyword' && PAREN_KEYWORD_TYPE_RE.test(nodeType) && !NO_PAREN_KEYWORD_TYPE_RE.test(nodeType)) { return 'Statement'; } // Part of a function definition (declaration, expression, method, etc.) if (FUNCTION_TYPE_RE.test(nodeType) && // Name is optional for function expressions (prevToken.type === 'Identifier' || prevToken.value === 'function')) { return 'Function'; } // Part of a call expression var prevNode = file.getNodeByRange(prevToken.range[0]); if ((nodeType === 'CallExpression' || nodeType === 'NewExpression') && // Must not be inside an arguments list or other grouping parentheses prevToken.value !== ',' && prevToken.value !== '(' && // If the callee is parenthesized (e.g., `(foo.bar)()`), prevNode will match node // Otherwise (e.g., `foo.bar()`), prevToken must be the last token of the callee node (prevNode === node || prevToken === file.getLastNodeToken(node.callee))) { return 'CallExpression'; } // All remaining cases are grouping parentheses return 'ParenthesizedExpression'; }; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!prevToken) {··· return 'ParenthesizedExpression'; } |
| ✓ Negative was executed (else) | }··· // Part of a parentheses-bearing statement (if, with, while, switch, etc.) |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | !NO_PAREN_KEYWORD_TYPE_RE.test(nodeType)) {··· return 'Statement'; } |
| ✓ Negative was executed (else) | }··· // Part of a function definition (declaration, expression, method, etc.) |
| Branch LogicalExpression | |
| ✓ Was returned | !NO_PAREN_KEYWORD_TYPE_RE.test(nodeType)) { |
| ✓ Was returned | if (prevToken.type === 'Keyword' && PAREN_KEYWORD_TYPE_RE.test(nodeType) && |
| Branch LogicalExpression | |
| ✓ Was returned | if (prevToken.type === 'Keyword' && PAREN_KEYWORD_TYPE_RE.test(nodeType) && |
| ✓ Was returned | if (prevToken.type === 'Keyword' && PAREN_KEYWORD_TYPE_RE.test(nodeType) && |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | (prevToken.type === 'Identifier' || prevToken.value === 'function')) {··· return 'Function'; } |
| ✓ Negative was executed (else) | }··· // Part of a call expression |
| Branch LogicalExpression | |
| ✓ Was returned | (prevToken.type === 'Identifier' || prevToken.value === 'function')) { |
| ✓ Was returned | if (FUNCTION_TYPE_RE.test(nodeType) && |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | (prevToken.type === 'Identifier' || prevToken.value === 'function')) { |
| ✓ Was returned | (prevToken.type === 'Identifier' || prevToken.value === 'function')) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | (prevNode === node || prevToken === file.getLastNodeToken(node.callee))) {··· return 'CallExpression'; } |
| ✓ Negative was executed (else) | }··· // All remaining cases are grouping parentheses |
| Branch LogicalExpression | |
| ✓ Was returned | (prevNode === node || prevToken === file.getLastNodeToken(node.callee))) { |
| ✓ Was returned | if ((nodeType === 'CallExpression' || nodeType === 'NewExpression') &&··· // Must not be inside an arguments list or other grouping parentheses prevToken.value !== ',' && prevToken.value !== '(' && |
| Branch LogicalExpression | |
| ✓ Was returned | prevToken.value !== ',' && prevToken.value !== '(' && |
| ✓ Was returned | if ((nodeType === 'CallExpression' || nodeType === 'NewExpression') &&··· // Must not be inside an arguments list or other grouping parentheses prevToken.value !== ',' && prevToken.value !== '(' && |
| Branch LogicalExpression | |
| ✓ Was returned | prevToken.value !== ',' && prevToken.value !== '(' && |
| ✓ Was returned | if ((nodeType === 'CallExpression' || nodeType === 'NewExpression') && |
| Branch LogicalExpression | |
| ✓ Was returned | if ((nodeType === 'CallExpression' || nodeType === 'NewExpression') && |
| ✓ Was returned | if ((nodeType === 'CallExpression' || nodeType === 'NewExpression') && |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | (prevNode === node || prevToken === file.getLastNodeToken(node.callee))) { |
| ✓ Was returned | (prevNode === node || prevToken === file.getLastNodeToken(node.callee))) { |
| Function (anonymous_695) | |
|---|---|
| ✓ Was called | exports.categorizeCloseParen = function(token, file) {··· assert(token.value === ')', 'Input token must be a parenthesis'); var node = file.getNodeByRange(token.range[0]); var nodeType = node.type; var nextToken = file.getNextToken(token); // Terminal statement if (nextToken.type === 'EOF') { switch (nodeType) { case 'DoWhileStatement': return 'Statement'; case 'CallExpression': case 'NewExpression': return 'CallExpression'; default: return 'ParenthesizedExpression'; } } // Part of a parentheses-bearing statement (if, with, while, switch, etc.) if (PAREN_KEYWORD_TYPE_RE.test(nodeType) && !NO_PAREN_KEYWORD_TYPE_RE.test(nodeType)) { // Closing parentheses for `switch` and `catch` must be followed by "{" // Closing parentheses for `do..while` may be the last punctuation inside a block if (nextToken.value === '{' || nextToken.value === '}') { return 'Statement'; } // Closing parentheses for other statements must be followed by a statement or declaration var nextNode = file.getNodeByRange(nextToken.range[0]); while (nextNode.range[0] >= token.range[1]) { if (QUASI_STATEMENT_TYPE_RE.test(nextNode.type)) { return 'Statement'; } nextNode = nextNode.parentNode; } } // Part of a function definition (declaration, expression, method, etc.) if (nextToken.value === '{' && FUNCTION_TYPE_RE.test(nodeType)) { return 'Function'; } // Part of a call expression if ((nodeType === 'CallExpression' || nodeType === 'NewExpression') && nextToken.range[0] >= node.range[1]) { return 'CallExpression'; } // All remaining cases are grouping parentheses return 'ParenthesizedExpression'; }; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (nextToken.type === 'EOF') {··· switch (nodeType) { case 'DoWhileStatement': return 'Statement'; case 'CallExpression': case 'NewExpression': return 'CallExpression'; default: return 'ParenthesizedExpression'; } } |
| ✓ Negative was executed (else) | }··· // Part of a parentheses-bearing statement (if, with, while, switch, etc.) |
| Branch SwitchStatement | |
|---|---|
| ✓ Was evaluated | case 'DoWhileStatement':··· return 'Statement'; |
| ✓ Was evaluated | case 'CallExpression': |
| ✓ Was evaluated | case 'NewExpression':··· return 'CallExpression'; |
| ✓ Was evaluated | default:··· return 'ParenthesizedExpression'; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (PAREN_KEYWORD_TYPE_RE.test(nodeType) && !NO_PAREN_KEYWORD_TYPE_RE.test(nodeType)) {··· // Closing parentheses for `switch` and `catch` must be followed by "{" // Closing parentheses for `do..while` may be the last punctuation inside a block if (nextToken.value === '{' || nextToken.value === '}') { return 'Statement'; } // Closing parentheses for other statements must be followed by a statement or declaration var nextNode = file.getNodeByRange(nextToken.range[0]); while (nextNode.range[0] >= token.range[1]) { if (QUASI_STATEMENT_TYPE_RE.test(nextNode.type)) { return 'Statement'; } nextNode = nextNode.parentNode; } } |
| ✓ Negative was executed (else) | }··· // Part of a function definition (declaration, expression, method, etc.) |
| Branch LogicalExpression | |
| ✓ Was returned | if (PAREN_KEYWORD_TYPE_RE.test(nodeType) && !NO_PAREN_KEYWORD_TYPE_RE.test(nodeType)) { |
| ✓ Was returned | if (PAREN_KEYWORD_TYPE_RE.test(nodeType) && !NO_PAREN_KEYWORD_TYPE_RE.test(nodeType)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (nextToken.value === '{' || nextToken.value === '}') {··· return 'Statement'; } |
| ✓ Negative was executed (else) | }··· // Closing parentheses for other statements must be followed by a statement or declaration |
| Branch LogicalExpression | |
| ✓ Was returned | if (nextToken.value === '{' || nextToken.value === '}') { |
| ✓ Was returned | if (nextToken.value === '{' || nextToken.value === '}') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (QUASI_STATEMENT_TYPE_RE.test(nextNode.type)) {··· return 'Statement'; } |
| ✗ Negative was not executed (else) | }··· nextNode = nextNode.parentNode; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (nextToken.value === '{' && FUNCTION_TYPE_RE.test(nodeType)) {··· return 'Function'; } |
| ✓ Negative was executed (else) | }··· // Part of a call expression |
| Branch LogicalExpression | |
| ✓ Was returned | if (nextToken.value === '{' && FUNCTION_TYPE_RE.test(nodeType)) { |
| ✓ Was returned | if (nextToken.value === '{' && FUNCTION_TYPE_RE.test(nodeType)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | nextToken.range[0] >= node.range[1]) {··· return 'CallExpression'; } |
| ✓ Negative was executed (else) | }··· // All remaining cases are grouping parentheses |
| Branch LogicalExpression | |
| ✓ Was returned | nextToken.range[0] >= node.range[1]) { |
| ✓ Was returned | if ((nodeType === 'CallExpression' || nodeType === 'NewExpression') && |
| Branch LogicalExpression | |
| ✓ Was returned | if ((nodeType === 'CallExpression' || nodeType === 'NewExpression') && |
| ✓ Was returned | if ((nodeType === 'CallExpression' || nodeType === 'NewExpression') && |
| Function (anonymous_696) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_697) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_698) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowSpacesInsideTemplateStringPlaceholders'; }, |
| Function (anonymous_699) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('TemplateLiteral', function(node) { var first = file.getFirstNodeToken(node); var last = file.getLastNodeToken(node); // Iterate over tokens inside TemplateLiteral node. for (var token = first; ; token = file.getNextToken(token)) { if (containsPlaceholderStart(token)) { var nextFist = file.getNextToken(token, {includeWhitespace: true}); if (nextFist.isWhitespace) { errors.assert.noWhitespaceBetween({ token: token, nextToken: file.getNextToken(token), message: 'Illegal space after "${"' }); } } if (containsPlaceholderEnd(token)) { var prevLast = file.getPrevToken(token, {includeWhitespace: true}); if (prevLast.isWhitespace) { errors.assert.noWhitespaceBetween({ token: file.getPrevToken(token), nextToken: token, message: 'Illegal space before "}"' }); } } if (token === last) { return; } } }); } |
| Function (anonymous_700) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('TemplateLiteral', function(node) {··· var first = file.getFirstNodeToken(node); var last = file.getLastNodeToken(node); // Iterate over tokens inside TemplateLiteral node. for (var token = first; ; token = file.getNextToken(token)) { if (containsPlaceholderStart(token)) { var nextFist = file.getNextToken(token, {includeWhitespace: true}); if (nextFist.isWhitespace) { errors.assert.noWhitespaceBetween({ token: token, nextToken: file.getNextToken(token), message: 'Illegal space after "${"' }); } } if (containsPlaceholderEnd(token)) { var prevLast = file.getPrevToken(token, {includeWhitespace: true}); if (prevLast.isWhitespace) { errors.assert.noWhitespaceBetween({ token: file.getPrevToken(token), nextToken: token, message: 'Illegal space before "}"' }); } } if (token === last) { return; } } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (containsPlaceholderStart(token)) {··· var nextFist = file.getNextToken(token, {includeWhitespace: true}); if (nextFist.isWhitespace) { errors.assert.noWhitespaceBetween({ token: token, nextToken: file.getNextToken(token), message: 'Illegal space after "${"' }); } } |
| ✓ Negative was executed (else) | }··· if (containsPlaceholderEnd(token)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (nextFist.isWhitespace) {··· errors.assert.noWhitespaceBetween({ token: token, nextToken: file.getNextToken(token), message: 'Illegal space after "${"' }); } |
| ✓ Negative was executed (else) | }··· } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (containsPlaceholderEnd(token)) {··· var prevLast = file.getPrevToken(token, {includeWhitespace: true}); if (prevLast.isWhitespace) { errors.assert.noWhitespaceBetween({ token: file.getPrevToken(token), nextToken: token, message: 'Illegal space before "}"' }); } } |
| ✓ Negative was executed (else) | }··· if (token === last) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (prevLast.isWhitespace) {··· errors.assert.noWhitespaceBetween({ token: file.getPrevToken(token), nextToken: token, message: 'Illegal space before "}"' }); } |
| ✓ Negative was executed (else) | }··· } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (token === last) {··· return; } |
| ✓ Negative was executed (else) | }··· } |
| Function containsPlaceholderStart | |
|---|---|
| ✓ Was called | function containsPlaceholderStart(token) {··· return token.type === 'Template' && /\${$/.test(token.value); } |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | return token.type === 'Template' && /\${$/.test(token.value); |
| ✓ Was returned | return token.type === 'Template' && /\${$/.test(token.value); |
| Function containsPlaceholderEnd | |
|---|---|
| ✓ Was called | function containsPlaceholderEnd(token) {··· return token.type === 'Template' && /^}/.test(token.value); } |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | return token.type === 'Template' && /^}/.test(token.value); |
| ✓ Was returned | return token.type === 'Template' && /^}/.test(token.value); |
| Function (anonymous_703) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_704) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_705) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowTabs'; }, |
| Function (anonymous_706) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.getLines().forEach(function(line, i) { var match = line.match(/\t/); if (match) { errors.add('Tab found', i + 1, match.index); } }); } |
| Function (anonymous_707) | |
|---|---|
| ✓ Was called | file.getLines().forEach(function(line, i) {··· var match = line.match(/\t/); if (match) { errors.add('Tab found', i + 1, match.index); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (match) {··· errors.add('Tab found', i + 1, match.index); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_708) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_709) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_710) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowTrailingComma'; }, |
| Function (anonymous_711) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType([ 'ObjectExpression', 'ArrayExpression', 'ObjectPattern', 'ArrayPattern' ], function(node) { var closingToken = file.getLastNodeToken(node); errors.assert.noTokenBefore({ token: closingToken, expectedTokenBefore: {type: 'Punctuator', value: ','}, message: 'Extra comma following the final element of an array or object literal' }); }); } |
| Function (anonymous_712) | |
|---|---|
| ✓ Was called | ], function(node) {··· var closingToken = file.getLastNodeToken(node); errors.assert.noTokenBefore({ token: closingToken, expectedTokenBefore: {type: 'Punctuator', value: ','}, message: 'Extra comma following the final element of an array or object literal' }); }); |
| Function (anonymous_713) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_714) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true || options === 'ignoreEmptyLines', this.getOptionName() + ' option requires a true value or "ignoreEmptyLines"' ); this._ignoreEmptyLines = options === 'ignoreEmptyLines'; }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options === true || options === 'ignoreEmptyLines', |
| ✓ Was returned | options === true || options === 'ignoreEmptyLines', |
| Function (anonymous_715) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowTrailingWhitespace'; }, |
| Function (anonymous_716) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var ignoreEmptyLines = this._ignoreEmptyLines; var lines = file.getLines(); for (var i = 0, l = lines.length; i < l; i++) { if (lines[i].match(/\s$/) && !(ignoreEmptyLines && lines[i].match(/^\s*$/))) { errors.cast({ message: 'Illegal trailing whitespace', line: i + 1, column: lines[i].length }); } } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (lines[i].match(/\s$/) && !(ignoreEmptyLines && lines[i].match(/^\s*$/))) {··· errors.cast({ message: 'Illegal trailing whitespace', line: i + 1, column: lines[i].length }); } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | if (lines[i].match(/\s$/) && !(ignoreEmptyLines && lines[i].match(/^\s*$/))) { |
| ✓ Was returned | if (lines[i].match(/\s$/) && !(ignoreEmptyLines && lines[i].match(/^\s*$/))) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (lines[i].match(/\s$/) && !(ignoreEmptyLines && lines[i].match(/^\s*$/))) { |
| ✓ Was returned | if (lines[i].match(/\s$/) && !(ignoreEmptyLines && lines[i].match(/^\s*$/))) { |
| Function (anonymous_717) | |
|---|---|
| ✓ Was called | _fix: function(file, error) {··· var ignoreEmptyLines = this._ignoreEmptyLines; var currentLineNumber = error.line; var linebreak = file.getLineBreaks()[0] || '\n'; var lines = file.getLines(); var fixed = false; var startLineNumber; var precedingToken; var targetToken; while (!precedingToken && currentLineNumber > 0) { precedingToken = file.getLastTokenOnLine(currentLineNumber, { includeComments: true }); currentLineNumber--; } if (precedingToken === null) { targetToken = file.getFirstToken({includeComments: true}); startLineNumber = 1; } else { targetToken = file.getNextToken(precedingToken, { includeComments: true }); startLineNumber = precedingToken.loc.end.line; if (precedingToken.isComment && precedingToken.loc.start.line <= error.line && precedingToken.loc.end.line >= error.line) { if (precedingToken.type === 'Block') { if (ignoreEmptyLines) { var blockLines = precedingToken.value.split(/\r\n|\n|\r/); for (var k = 0; k < blockLines.length; k++) { if (!blockLines[k].match(/^\s*$/) || k === 0) { blockLines[k] = blockLines[k].split(/\s+$/).join(''); } } precedingToken.value = blockLines.join(linebreak); } else { precedingToken.value = precedingToken.value .split(/[^\S\r\n]+\r\n|[^\S\n]+\n|[^\S\r]+\r/) .join(linebreak); } } else { precedingToken.value = precedingToken.value.split(/\s+$/).join(''); } fixed = true; } } if (targetToken !== null && !fixed) { var eolCount = targetToken.loc.start.line - startLineNumber + 1; var targetIndent = ''; var targetLine = lines[targetToken.loc.start.line - 1]; for (var j = 0, whitespace = targetLine.charAt(j); whitespace.match(/\s/); j++, whitespace = targetLine.charAt(j)) { targetIndent += whitespace; } file.setWhitespaceBefore(targetToken, new Array(eolCount).join(linebreak) + targetIndent); fixed = true; } if (!fixed && precedingToken && precedingToken.type === 'EOF') { precedingToken = file.getPrevToken(precedingToken, { includeWhitespace: true }); if (precedingToken.isWhitespace) { precedingToken.value = precedingToken.value.replace(/[^\S\n\r]$/g, ''); fixed = true; } } if (!fixed) { error.fixed = false; } } |
| Branch LogicalExpression | |
|---|---|
| ✗ Was not returned | var linebreak = file.getLineBreaks()[0] || '\n'; |
| ✓ Was returned | var linebreak = file.getLineBreaks()[0] || '\n'; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | while (!precedingToken && currentLineNumber > 0) { |
| ✓ Was returned | while (!precedingToken && currentLineNumber > 0) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (precedingToken === null) {··· targetToken = file.getFirstToken({includeComments: true}); startLineNumber = 1; } else { |
| ✓ Negative was executed (else) | } else {··· targetToken = file.getNextToken(precedingToken, { includeComments: true }); startLineNumber = precedingToken.loc.end.line; if (precedingToken.isComment && precedingToken.loc.start.line <= error.line && precedingToken.loc.end.line >= error.line) { if (precedingToken.type === 'Block') { if (ignoreEmptyLines) { var blockLines = precedingToken.value.split(/\r\n|\n|\r/); for (var k = 0; k < blockLines.length; k++) { if (!blockLines[k].match(/^\s*$/) || k === 0) { blockLines[k] = blockLines[k].split(/\s+$/).join(''); } } precedingToken.value = blockLines.join(linebreak); } else { precedingToken.value = precedingToken.value .split(/[^\S\r\n]+\r\n|[^\S\n]+\n|[^\S\r]+\r/) .join(linebreak); } } else { precedingToken.value = precedingToken.value.split(/\s+$/).join(''); } fixed = true; } } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | precedingToken.loc.end.line >= error.line) {··· if (precedingToken.type === 'Block') { if (ignoreEmptyLines) { var blockLines = precedingToken.value.split(/\r\n|\n|\r/); for (var k = 0; k < blockLines.length; k++) { if (!blockLines[k].match(/^\s*$/) || k === 0) { blockLines[k] = blockLines[k].split(/\s+$/).join(''); } } precedingToken.value = blockLines.join(linebreak); } else { precedingToken.value = precedingToken.value .split(/[^\S\r\n]+\r\n|[^\S\n]+\n|[^\S\r]+\r/) .join(linebreak); } } else { precedingToken.value = precedingToken.value.split(/\s+$/).join(''); } fixed = true; } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | precedingToken.loc.end.line >= error.line) { |
| ✓ Was returned | if (precedingToken.isComment &&··· precedingToken.loc.start.line <= error.line && |
| Branch LogicalExpression | |
| ✓ Was returned | precedingToken.loc.start.line <= error.line && |
| ✓ Was returned | if (precedingToken.isComment && |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (precedingToken.type === 'Block') {··· if (ignoreEmptyLines) { var blockLines = precedingToken.value.split(/\r\n|\n|\r/); for (var k = 0; k < blockLines.length; k++) { if (!blockLines[k].match(/^\s*$/) || k === 0) { blockLines[k] = blockLines[k].split(/\s+$/).join(''); } } precedingToken.value = blockLines.join(linebreak); } else { precedingToken.value = precedingToken.value .split(/[^\S\r\n]+\r\n|[^\S\n]+\n|[^\S\r]+\r/) .join(linebreak); } } else { |
| ✓ Negative was executed (else) | } else {··· precedingToken.value = precedingToken.value.split(/\s+$/).join(''); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (ignoreEmptyLines) {··· var blockLines = precedingToken.value.split(/\r\n|\n|\r/); for (var k = 0; k < blockLines.length; k++) { if (!blockLines[k].match(/^\s*$/) || k === 0) { blockLines[k] = blockLines[k].split(/\s+$/).join(''); } } precedingToken.value = blockLines.join(linebreak); } else { |
| ✓ Negative was executed (else) | } else {··· precedingToken.value = precedingToken.value .split(/[^\S\r\n]+\r\n|[^\S\n]+\n|[^\S\r]+\r/) .join(linebreak); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!blockLines[k].match(/^\s*$/) || k === 0) {··· blockLines[k] = blockLines[k].split(/\s+$/).join(''); } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | if (!blockLines[k].match(/^\s*$/) || k === 0) { |
| ✓ Was returned | if (!blockLines[k].match(/^\s*$/) || k === 0) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (targetToken !== null && !fixed) {··· var eolCount = targetToken.loc.start.line - startLineNumber + 1; var targetIndent = ''; var targetLine = lines[targetToken.loc.start.line - 1]; for (var j = 0, whitespace = targetLine.charAt(j); whitespace.match(/\s/); j++, whitespace = targetLine.charAt(j)) { targetIndent += whitespace; } file.setWhitespaceBefore(targetToken, new Array(eolCount).join(linebreak) + targetIndent); fixed = true; } |
| ✓ Negative was executed (else) | }··· if (!fixed && precedingToken && precedingToken.type === 'EOF') { |
| Branch LogicalExpression | |
| ✓ Was returned | if (targetToken !== null && !fixed) { |
| ✓ Was returned | if (targetToken !== null && !fixed) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!fixed && precedingToken && precedingToken.type === 'EOF') {··· precedingToken = file.getPrevToken(precedingToken, { includeWhitespace: true }); if (precedingToken.isWhitespace) { precedingToken.value = precedingToken.value.replace(/[^\S\n\r]$/g, ''); fixed = true; } } |
| ✓ Negative was executed (else) | }··· if (!fixed) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (!fixed && precedingToken && precedingToken.type === 'EOF') { |
| ✓ Was returned | if (!fixed && precedingToken && precedingToken.type === 'EOF') { |
| Branch LogicalExpression | |
| ✓ Was returned | if (!fixed && precedingToken && precedingToken.type === 'EOF') { |
| ✓ Was returned | if (!fixed && precedingToken && precedingToken.type === 'EOF') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (precedingToken.isWhitespace) {··· precedingToken.value = precedingToken.value.replace(/[^\S\n\r]$/g, ''); fixed = true; } |
| ✗ Negative was not executed (else) | }··· } |
| Branch IfStatement | |
|---|---|
| ✗ Positive was not executed (if) | if (!fixed) {··· error.fixed = false; } |
| ✓ Negative was executed (else) | }··· } |
| Function getUsedParams | |
|---|---|
| ✓ Was called | function getUsedParams(scope) {··· var vars; var res = []; if (scope.type === 'function-expression-name') { scope = scope.childScopes[0]; } var length = scope.block.params.length; for (var i = 0; i <= length; i++) { vars = scope.variables[i]; if (vars.name === 'arguments') { continue; } res.push({ param: vars, used: !!vars.references.length }); } var used = false; res.reverse().forEach(function(param) { if (used) { param.used = true; return; } if (param.used) { used = true; } }); return res.reverse(); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (scope.type === 'function-expression-name') {··· scope = scope.childScopes[0]; } |
| ✓ Negative was executed (else) | }··· var length = scope.block.params.length; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (vars.name === 'arguments') {··· continue; } |
| ✓ Negative was executed (else) | }··· res.push({ |
| Function (anonymous_719) | |
|---|---|
| ✓ Was called | res.reverse().forEach(function(param) {··· if (used) { param.used = true; return; } if (param.used) { used = true; } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (used) {··· param.used = true; return; } |
| ✓ Negative was executed (else) | }··· if (param.used) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (param.used) {··· used = true; } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_720) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_721) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_722) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowUnusedParams'; }, |
| Function (anonymous_723) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) { var scope = file.getScope().acquire(node); var params = node.params; getUsedParams(scope).forEach(function(value, index) { if (value.used) { return; } var param = params[index]; errors.cast({ message: 'Param `' + value.param.name + '` is not used', line: param.loc.start.line, column: param.loc.start.column, additional: { node: param, token: file.getFirstNodeToken(param) } }); }); }); }, |
| Function (anonymous_724) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) {··· var scope = file.getScope().acquire(node); var params = node.params; getUsedParams(scope).forEach(function(value, index) { if (value.used) { return; } var param = params[index]; errors.cast({ message: 'Param `' + value.param.name + '` is not used', line: param.loc.start.line, column: param.loc.start.column, additional: { node: param, token: file.getFirstNodeToken(param) } }); }); }); |
| Function (anonymous_725) | |
|---|---|
| ✓ Was called | getUsedParams(scope).forEach(function(value, index) {··· if (value.used) { return; } var param = params[index]; errors.cast({ message: 'Param `' + value.param.name + '` is not used', line: param.loc.start.line, column: param.loc.start.column, additional: { node: param, token: file.getFirstNodeToken(param) } }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value.used) {··· return; } |
| ✓ Negative was executed (else) | }··· var param = params[index]; |
| Function (anonymous_726) | |
|---|---|
| ✓ Was called | _fix: function(file, error) {··· var node = error.additional.node; var parent = node.parentNode; var index = parent.params.indexOf(node); var length = parent.params.length; var token = error.additional.token; var next; if (parent.params[index + 1]) { next = file.findNextToken(token, 'Identifier'); } // For "b" // function test(b) {} if (length === 1) { file.removeToken(token); return; } // function test(a, b) {} if (length > 1 && index + 1 === length) { file.removeEntity(parent.params, node); var comma = file.findPrevToken(token, 'Punctuator', ','); file.setWhitespaceBefore(comma, ''); file.removeToken(comma); file.setWhitespaceBefore(token, ''); file.removeToken(token); return; } // function test(b, c) {} if (length > 1) { file.removeEntity(parent.params, node); file.removeToken(file.findNextToken(token, 'Punctuator', ',')); file.setWhitespaceBefore(next, ''); file.removeToken(token); return; } } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (parent.params[index + 1]) {··· next = file.findNextToken(token, 'Identifier'); } |
| ✓ Negative was executed (else) | }··· // For "b" |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (length === 1) {··· file.removeToken(token); return; } |
| ✓ Negative was executed (else) | }··· // function test(a, b) {} |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (length > 1 && index + 1 === length) {··· file.removeEntity(parent.params, node); var comma = file.findPrevToken(token, 'Punctuator', ','); file.setWhitespaceBefore(comma, ''); file.removeToken(comma); file.setWhitespaceBefore(token, ''); file.removeToken(token); return; } |
| ✓ Negative was executed (else) | }··· // function test(b, c) {} |
| Branch LogicalExpression | |
| ✓ Was returned | if (length > 1 && index + 1 === length) { |
| ✗ Was not returned | if (length > 1 && index + 1 === length) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (length > 1) {··· file.removeEntity(parent.params, node); file.removeToken(file.findNextToken(token, 'Punctuator', ',')); file.setWhitespaceBefore(next, ''); file.removeToken(token); return; } |
| ✗ Negative was not executed (else) | }··· } |
| Function (anonymous_727) | |
|---|---|
| ✓ Was called | module.exports = function() { }; |
| Function (anonymous_728) | |
|---|---|
| ✓ Was called | configure: function(option) {··· assert(option === true, this.getOptionName() + ' requires a true value'); }, |
| Function (anonymous_729) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowVar'; }, |
| Function (anonymous_730) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('VariableDeclaration', function(node) { for (var i = 0; i < node.declarations.length; i++) { var thisDeclaration = node.declarations[i]; if (thisDeclaration.parentNode.kind === 'var') { errors.add( 'Variable declarations should use `let` or `const` not `var`', node.loc.start ); } } }); } |
| Function (anonymous_731) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('VariableDeclaration', function(node) {··· for (var i = 0; i < node.declarations.length; i++) { var thisDeclaration = node.declarations[i]; if (thisDeclaration.parentNode.kind === 'var') { errors.add( 'Variable declarations should use `let` or `const` not `var`', node.loc.start ); } } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (thisDeclaration.parentNode.kind === 'var') {··· errors.add( 'Variable declarations should use `let` or `const` not `var`', node.loc.start ); } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_732) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_733) | |
|---|---|
| ✓ Was called | configure: function(operators) {··· var isTrue = operators === true; assert( Array.isArray(operators) || isTrue, this.getOptionName() + ' option requires array or true value' ); if (isTrue) { operators = ['==', '===', '!=', '!==']; } this._operatorIndex = {}; for (var i = 0, l = operators.length; i < l; i++) { this._operatorIndex[operators[i]] = true; } }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | Array.isArray(operators) || isTrue, |
| ✓ Was returned | Array.isArray(operators) || isTrue, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isTrue) {··· operators = ['==', '===', '!=', '!==']; } |
| ✓ Negative was executed (else) | }··· this._operatorIndex = {}; |
| Function (anonymous_734) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'disallowYodaConditions'; }, |
| Function (anonymous_735) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var operators = this._operatorIndex; file.iterateNodesByType('BinaryExpression', function(node) { if (operators[node.operator]) { if (node.left.type === 'Literal' || (node.left.type === 'Identifier' && node.left.name === 'undefined') ) { errors.add('Yoda condition', node.left.loc.start); } } }); } |
| Function (anonymous_736) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('BinaryExpression', function(node) {··· if (operators[node.operator]) { if (node.left.type === 'Literal' || (node.left.type === 'Identifier' && node.left.name === 'undefined') ) { errors.add('Yoda condition', node.left.loc.start); } } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (operators[node.operator]) {··· if (node.left.type === 'Literal' || (node.left.type === 'Identifier' && node.left.name === 'undefined') ) { errors.add('Yoda condition', node.left.loc.start); } } |
| ✓ Negative was executed (else) | }··· }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | ) {··· errors.add('Yoda condition', node.left.loc.start); } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | (node.left.type === 'Identifier' && node.left.name === 'undefined') |
| ✓ Was returned | if (node.left.type === 'Literal' || |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | (node.left.type === 'Identifier' && node.left.name === 'undefined') |
| ✓ Was returned | (node.left.type === 'Identifier' && node.left.name === 'undefined') |
| Function (anonymous_737) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_738) | |
|---|---|
| ✓ Was called | configure: function(maximumLineLength) {··· this._tabSize = ''; this._allowRegex = false; this._allowComments = false; this._allowUrlComments = false; this._allowRequire = false; if (typeof maximumLineLength === 'object') { assert( typeof maximumLineLength.value === 'number', this.getOptionName() + ' option requires the "value" property to be defined' ); this._maximumLineLength = maximumLineLength.value; var tabSize = maximumLineLength.tabSize || 0; while (tabSize--) { this._tabSize += ' '; } var exceptions = maximumLineLength.allExcept || []; this._allowRegex = (exceptions.indexOf('regex') !== -1); this._allowComments = (exceptions.indexOf('comments') !== -1); this._allowUrlComments = (exceptions.indexOf('urlComments') !== -1); this._allowFunctionSignature = (exceptions.indexOf('functionSignature') !== -1); this._allowRequire = (exceptions.indexOf('require') !== -1); if (maximumLineLength.hasOwnProperty('allowRegex')) { this._allowRegex = (maximumLineLength.allowRegex === true); } if (maximumLineLength.hasOwnProperty('allowComments')) { this._allowComments = (maximumLineLength.allowComments === true); } if (maximumLineLength.hasOwnProperty('allowUrlComments')) { this._allowUrlComments = (maximumLineLength.allowUrlComments === true); } } else { assert( typeof maximumLineLength === 'number', this.getOptionName() + ' option requires number value or options object' ); this._maximumLineLength = maximumLineLength; } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof maximumLineLength === 'object') {··· assert( typeof maximumLineLength.value === 'number', this.getOptionName() + ' option requires the "value" property to be defined' ); this._maximumLineLength = maximumLineLength.value; var tabSize = maximumLineLength.tabSize || 0; while (tabSize--) { this._tabSize += ' '; } var exceptions = maximumLineLength.allExcept || []; this._allowRegex = (exceptions.indexOf('regex') !== -1); this._allowComments = (exceptions.indexOf('comments') !== -1); this._allowUrlComments = (exceptions.indexOf('urlComments') !== -1); this._allowFunctionSignature = (exceptions.indexOf('functionSignature') !== -1); this._allowRequire = (exceptions.indexOf('require') !== -1); if (maximumLineLength.hasOwnProperty('allowRegex')) { this._allowRegex = (maximumLineLength.allowRegex === true); } if (maximumLineLength.hasOwnProperty('allowComments')) { this._allowComments = (maximumLineLength.allowComments === true); } if (maximumLineLength.hasOwnProperty('allowUrlComments')) { this._allowUrlComments = (maximumLineLength.allowUrlComments === true); } } else { |
| ✓ Negative was executed (else) | } else {··· assert( typeof maximumLineLength === 'number', this.getOptionName() + ' option requires number value or options object' ); this._maximumLineLength = maximumLineLength; } |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | var tabSize = maximumLineLength.tabSize || 0; |
| ✓ Was returned | var tabSize = maximumLineLength.tabSize || 0; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | var exceptions = maximumLineLength.allExcept || []; |
| ✓ Was returned | var exceptions = maximumLineLength.allExcept || []; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (maximumLineLength.hasOwnProperty('allowRegex')) {··· this._allowRegex = (maximumLineLength.allowRegex === true); } |
| ✓ Negative was executed (else) | }··· if (maximumLineLength.hasOwnProperty('allowComments')) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (maximumLineLength.hasOwnProperty('allowComments')) {··· this._allowComments = (maximumLineLength.allowComments === true); } |
| ✓ Negative was executed (else) | }··· if (maximumLineLength.hasOwnProperty('allowUrlComments')) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (maximumLineLength.hasOwnProperty('allowUrlComments')) {··· this._allowUrlComments = (maximumLineLength.allowUrlComments === true); } |
| ✓ Negative was executed (else) | }··· } else { |
| Function (anonymous_739) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'maximumLineLength'; }, |
| Function (anonymous_740) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var maximumLineLength = this._maximumLineLength; var line; var lines = this._allowComments ? file.getLinesWithCommentsRemoved() : file.getLines(); // This check should not be destructive lines = lines.slice(); var removeLoc = function(tokenOrNode) { // Just in case (See #2107 for example) if (!tokenOrNode) { return; } for (var i = tokenOrNode.loc.start.line; i <= tokenOrNode.loc.end.line; i++) { lines[i - 1] = ''; } }; if (this._allowRegex) { file.iterateTokensByType('RegularExpression', function(token) { removeLoc(token); }); } if (this._allowUrlComments) { file.iterateTokensByType(['Line', 'Block'], function(comment) { for (var i = comment.loc.start.line; i <= comment.loc.end.line; i++) { lines[i - 1] = lines[i - 1].replace(/(http|https|ftp):\/\/[^\s$]+/, ''); } }); } if (this._allowFunctionSignature) { file.iterateNodesByType('FunctionDeclaration', function(node) { // Need to remove the first line, because we can't be sure there's any id or params lines[node.loc.start.line - 1] = ''; removeLoc(node.id); node.params.forEach(removeLoc); }); file.iterateNodesByType('MethodDefinition', function(node) { removeLoc(node.key); }); file.iterateNodesByType(['ArrowFunctionExpression', 'FunctionExpression'], function(node) { // Need to remove the first line, because we can't be sure there's any id or params lines[node.loc.start.line - 1] = ''; removeLoc(node.id); node.params.forEach(removeLoc); }); } if (this._allowRequire) { file.iterateNodesByType('CallExpression', function(node) { if (node.callee.name === 'require') { removeLoc(node); } }); } for (var i = 0, l = lines.length; i < l; i++) { line = this._tabSize ? lines[i].replace(/\t/g, this._tabSize) : lines[i]; if (line.length > maximumLineLength) { errors.add( 'Line must be at most ' + maximumLineLength + ' characters', i + 1, lines[i].length ); } } } |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | file.getLinesWithCommentsRemoved() : file.getLines(); |
| ✓ Negative was returned (: ...) | file.getLinesWithCommentsRemoved() : file.getLines(); |
| Function (anonymous_741) | |
|---|---|
| ✓ Was called | var removeLoc = function(tokenOrNode) {··· // Just in case (See #2107 for example) if (!tokenOrNode) { return; } for (var i = tokenOrNode.loc.start.line; i <= tokenOrNode.loc.end.line; i++) { lines[i - 1] = ''; } }; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!tokenOrNode) {··· return; } |
| ✓ Negative was executed (else) | }··· for (var i = tokenOrNode.loc.start.line; i <= tokenOrNode.loc.end.line; i++) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._allowRegex) {··· file.iterateTokensByType('RegularExpression', function(token) { removeLoc(token); }); } |
| ✓ Negative was executed (else) | }··· if (this._allowUrlComments) { |
| Function (anonymous_742) | |
|---|---|
| ✓ Was called | file.iterateTokensByType('RegularExpression', function(token) {··· removeLoc(token); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._allowUrlComments) {··· file.iterateTokensByType(['Line', 'Block'], function(comment) { for (var i = comment.loc.start.line; i <= comment.loc.end.line; i++) { lines[i - 1] = lines[i - 1].replace(/(http|https|ftp):\/\/[^\s$]+/, ''); } }); } |
| ✓ Negative was executed (else) | }··· if (this._allowFunctionSignature) { |
| Function (anonymous_743) | |
|---|---|
| ✓ Was called | file.iterateTokensByType(['Line', 'Block'], function(comment) {··· for (var i = comment.loc.start.line; i <= comment.loc.end.line; i++) { lines[i - 1] = lines[i - 1].replace(/(http|https|ftp):\/\/[^\s$]+/, ''); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._allowFunctionSignature) {··· file.iterateNodesByType('FunctionDeclaration', function(node) { // Need to remove the first line, because we can't be sure there's any id or params lines[node.loc.start.line - 1] = ''; removeLoc(node.id); node.params.forEach(removeLoc); }); file.iterateNodesByType('MethodDefinition', function(node) { removeLoc(node.key); }); file.iterateNodesByType(['ArrowFunctionExpression', 'FunctionExpression'], function(node) { // Need to remove the first line, because we can't be sure there's any id or params lines[node.loc.start.line - 1] = ''; removeLoc(node.id); node.params.forEach(removeLoc); }); } |
| ✓ Negative was executed (else) | }··· if (this._allowRequire) { |
| Function (anonymous_744) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('FunctionDeclaration', function(node) {··· // Need to remove the first line, because we can't be sure there's any id or params lines[node.loc.start.line - 1] = ''; removeLoc(node.id); node.params.forEach(removeLoc); }); |
| Function (anonymous_745) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('MethodDefinition', function(node) {··· removeLoc(node.key); }); |
| Function (anonymous_746) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['ArrowFunctionExpression', 'FunctionExpression'], function(node) {··· // Need to remove the first line, because we can't be sure there's any id or params lines[node.loc.start.line - 1] = ''; removeLoc(node.id); node.params.forEach(removeLoc); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._allowRequire) {··· file.iterateNodesByType('CallExpression', function(node) { if (node.callee.name === 'require') { removeLoc(node); } }); } |
| ✓ Negative was executed (else) | }··· for (var i = 0, l = lines.length; i < l; i++) { |
| Function (anonymous_747) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('CallExpression', function(node) {··· if (node.callee.name === 'require') { removeLoc(node); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.callee.name === 'require') {··· removeLoc(node); } |
| ✗ Negative was not executed (else) | }··· }); |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | line = this._tabSize ? lines[i].replace(/\t/g, this._tabSize) : lines[i]; |
| ✓ Negative was returned (: ...) | line = this._tabSize ? lines[i].replace(/\t/g, this._tabSize) : lines[i]; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (line.length > maximumLineLength) {··· errors.add( 'Line must be at most ' + maximumLineLength + ' characters', i + 1, lines[i].length ); } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_748) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_749) | |
|---|---|
| ✓ Was called | configure: function(options) {··· this._allowComments = true; if (typeof options === 'number') { assert( typeof options === 'number', this.getOptionName() + ' option requires number value or options object' ); this._maximumNumberOfLines = options; } else { assert( typeof options.value === 'number', this.getOptionName() + ' option requires the "value" property to be defined' ); this._maximumNumberOfLines = options.value; var exceptions = options.allExcept || []; this._allowComments = (exceptions.indexOf('comments') === -1); } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof options === 'number') {··· assert( typeof options === 'number', this.getOptionName() + ' option requires number value or options object' ); this._maximumNumberOfLines = options; } else { |
| ✓ Negative was executed (else) | } else {··· assert( typeof options.value === 'number', this.getOptionName() + ' option requires the "value" property to be defined' ); this._maximumNumberOfLines = options.value; var exceptions = options.allExcept || []; this._allowComments = (exceptions.indexOf('comments') === -1); } |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | var exceptions = options.allExcept || []; |
| ✓ Was returned | var exceptions = options.allExcept || []; |
| Function (anonymous_750) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'maximumNumberOfLines'; }, |
| Function (anonymous_751) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var firstToken = file.getFirstToken({includeComments: true}); var lines = this._allowComments ? file.getLines() : file.getLinesWithCommentsRemoved(); lines = lines.filter(function(line) {return line !== '';}); if (lines.length > this._maximumNumberOfLines) { errors.add('File must be at most ' + this._maximumNumberOfLines + ' lines long', firstToken.loc.end.line, firstToken.loc.end.column); } } |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | file.getLines() : file.getLinesWithCommentsRemoved(); |
| ✓ Negative was returned (: ...) | file.getLines() : file.getLinesWithCommentsRemoved(); |
| Function (anonymous_752) | |
|---|---|
| ✓ Was called | lines = lines.filter(function(line) {return line !== '';}); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (lines.length > this._maximumNumberOfLines) {··· errors.add('File must be at most ' + this._maximumNumberOfLines + ' lines long', firstToken.loc.end.line, firstToken.loc.end.column); } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_753) | |
|---|---|
| ✓ Was called | module.exports = function() {··· }; |
| Function (anonymous_754) | |
|---|---|
| ✓ Was called | configure: function(option) {··· if (typeof option === 'number') { this._indentationLevel = option; } else if (typeof option === 'string') { assert( option === 'firstParam', this.getOptionName() + ' option requires string value to be "firstParam"' ); this._alignWithFirstParam = true; } else if (option === true) { this._indentationLevel = 0; } else { assert( false, this.getOptionName() + ' option requires a valid option' ); } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof option === 'number') {··· this._indentationLevel = option; } else if (typeof option === 'string') { |
| ✓ Negative was executed (else) | } else if (typeof option === 'string') {··· assert( option === 'firstParam', this.getOptionName() + ' option requires string value to be "firstParam"' ); this._alignWithFirstParam = true; } else if (option === true) { this._indentationLevel = 0; } else { assert( false, this.getOptionName() + ' option requires a valid option' ); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (typeof option === 'string') {··· assert( option === 'firstParam', this.getOptionName() + ' option requires string value to be "firstParam"' ); this._alignWithFirstParam = true; } else if (option === true) { |
| ✓ Negative was executed (else) | } else if (option === true) {··· this._indentationLevel = 0; } else { assert( false, this.getOptionName() + ' option requires a valid option' ); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (option === true) {··· this._indentationLevel = 0; } else { |
| ✓ Negative was executed (else) | } else {··· assert( false, this.getOptionName() + ' option requires a valid option' ); } |
| Function (anonymous_755) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireAlignedMultilineParams'; }, |
| Function (anonymous_756) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var _this = this; file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) { var params = node.params; // We can pass the check if there's no params if (params.length === 0) { return; } var currentLine = params[0].loc.start.line; var referenceColumn; var body; if (_this._alignWithFirstParam) { referenceColumn = params[0].loc.start.column; } else { body = node.body.body[0]; // If function doesn't have a body just bail out (#1988) if (!body) { return; } referenceColumn = body.loc.start.column + _this._indentationLevel; } params.forEach(function(param) { if (param.loc.start.line !== currentLine) { if (param.loc.start.column !== referenceColumn) { errors.assert.indentation({ lineNumber: param.loc.start.line, actual: param.loc.start.column, expected: referenceColumn, indentChar: ' ', silent: false }); } currentLine = param.loc.start.line; } }); }); } |
| Function (anonymous_757) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) {··· var params = node.params; // We can pass the check if there's no params if (params.length === 0) { return; } var currentLine = params[0].loc.start.line; var referenceColumn; var body; if (_this._alignWithFirstParam) { referenceColumn = params[0].loc.start.column; } else { body = node.body.body[0]; // If function doesn't have a body just bail out (#1988) if (!body) { return; } referenceColumn = body.loc.start.column + _this._indentationLevel; } params.forEach(function(param) { if (param.loc.start.line !== currentLine) { if (param.loc.start.column !== referenceColumn) { errors.assert.indentation({ lineNumber: param.loc.start.line, actual: param.loc.start.column, expected: referenceColumn, indentChar: ' ', silent: false }); } currentLine = param.loc.start.line; } }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (params.length === 0) {··· return; } |
| ✓ Negative was executed (else) | }··· var currentLine = params[0].loc.start.line; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (_this._alignWithFirstParam) {··· referenceColumn = params[0].loc.start.column; } else { |
| ✓ Negative was executed (else) | } else {··· body = node.body.body[0]; // If function doesn't have a body just bail out (#1988) if (!body) { return; } referenceColumn = body.loc.start.column + _this._indentationLevel; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!body) {··· return; } |
| ✓ Negative was executed (else) | }··· referenceColumn = body.loc.start.column + _this._indentationLevel; |
| Function (anonymous_758) | |
|---|---|
| ✓ Was called | params.forEach(function(param) {··· if (param.loc.start.line !== currentLine) { if (param.loc.start.column !== referenceColumn) { errors.assert.indentation({ lineNumber: param.loc.start.line, actual: param.loc.start.column, expected: referenceColumn, indentChar: ' ', silent: false }); } currentLine = param.loc.start.line; } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (param.loc.start.line !== currentLine) {··· if (param.loc.start.column !== referenceColumn) { errors.assert.indentation({ lineNumber: param.loc.start.line, actual: param.loc.start.column, expected: referenceColumn, indentChar: ' ', silent: false }); } currentLine = param.loc.start.line; } |
| ✓ Negative was executed (else) | }··· }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (param.loc.start.column !== referenceColumn) {··· errors.assert.indentation({ lineNumber: param.loc.start.line, actual: param.loc.start.column, expected: referenceColumn, indentChar: ' ', silent: false }); } |
| ✓ Negative was executed (else) | }··· currentLine = param.loc.start.line; |
| Function (anonymous_759) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_760) | |
|---|---|
| ✓ Was called | configure: function(mode) {··· var modes = { 'all': 'all', 'ignoreFunction': 'ignoreFunction', 'ignoreLineBreak': 'ignoreLineBreak', 'skipWithFunction': 'ignoreFunction', 'skipWithLineBreak': 'ignoreLineBreak' }; assert( typeof mode === 'string' && modes[mode], this.getOptionName() + ' requires one of the following values: ' + Object.keys(modes).join(', ') ); this._mode = modes[mode]; }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | typeof mode === 'string' && modes[mode], |
| ✗ Was not returned | typeof mode === 'string' && modes[mode], |
| Function (anonymous_761) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireAlignedObjectValues'; }, |
| Function (anonymous_762) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var mode = this._mode; file.iterateNodesByType('ObjectExpression', function(node) { if (node.loc.start.line === node.loc.end.line || node.properties < 2) { return; } var maxKeyEndPos = 0; var prevKeyEndPos = 0; var minColonPos = 0; var tokens = []; var skip = node.properties.some(function(property, index) { if (property.shorthand || property.method || property.kind !== 'init' || node.type === 'SpreadProperty') { return true; } if (mode === 'ignoreFunction' && property.value.type === 'FunctionExpression') { return true; } if (mode === 'ignoreLineBreak' && index > 0 && node.properties[index - 1].loc.end.line !== property.loc.start.line - 1) { return true; } prevKeyEndPos = maxKeyEndPos; maxKeyEndPos = Math.max(maxKeyEndPos, property.key.loc.end.column); var keyToken = file.getFirstNodeToken(property.key); if (property.computed === true) { while (keyToken.value !== ']') { keyToken = file.getNextToken(keyToken); } } var colon = file.getNextToken(keyToken); if (prevKeyEndPos < maxKeyEndPos) { minColonPos = colon.loc.start.column; } tokens.push({key: keyToken, colon: colon}); }); if (skip) { return; } var space = minColonPos - maxKeyEndPos; tokens.forEach(function(pair) { errors.assert.spacesBetween({ token: pair.key, nextToken: pair.colon, exactly: maxKeyEndPos - pair.key.loc.end.column + space, message: 'Alignment required' }); }); }); } |
| Function (anonymous_763) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('ObjectExpression', function(node) {··· if (node.loc.start.line === node.loc.end.line || node.properties < 2) { return; } var maxKeyEndPos = 0; var prevKeyEndPos = 0; var minColonPos = 0; var tokens = []; var skip = node.properties.some(function(property, index) { if (property.shorthand || property.method || property.kind !== 'init' || node.type === 'SpreadProperty') { return true; } if (mode === 'ignoreFunction' && property.value.type === 'FunctionExpression') { return true; } if (mode === 'ignoreLineBreak' && index > 0 && node.properties[index - 1].loc.end.line !== property.loc.start.line - 1) { return true; } prevKeyEndPos = maxKeyEndPos; maxKeyEndPos = Math.max(maxKeyEndPos, property.key.loc.end.column); var keyToken = file.getFirstNodeToken(property.key); if (property.computed === true) { while (keyToken.value !== ']') { keyToken = file.getNextToken(keyToken); } } var colon = file.getNextToken(keyToken); if (prevKeyEndPos < maxKeyEndPos) { minColonPos = colon.loc.start.column; } tokens.push({key: keyToken, colon: colon}); }); if (skip) { return; } var space = minColonPos - maxKeyEndPos; tokens.forEach(function(pair) { errors.assert.spacesBetween({ token: pair.key, nextToken: pair.colon, exactly: maxKeyEndPos - pair.key.loc.end.column + space, message: 'Alignment required' }); }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.loc.start.line === node.loc.end.line || node.properties < 2) {··· return; } |
| ✓ Negative was executed (else) | }··· var maxKeyEndPos = 0; |
| Branch LogicalExpression | |
| ✓ Was returned | if (node.loc.start.line === node.loc.end.line || node.properties < 2) { |
| ✓ Was returned | if (node.loc.start.line === node.loc.end.line || node.properties < 2) { |
| Function (anonymous_764) | |
|---|---|
| ✓ Was called | var skip = node.properties.some(function(property, index) {··· if (property.shorthand || property.method || property.kind !== 'init' || node.type === 'SpreadProperty') { return true; } if (mode === 'ignoreFunction' && property.value.type === 'FunctionExpression') { return true; } if (mode === 'ignoreLineBreak' && index > 0 && node.properties[index - 1].loc.end.line !== property.loc.start.line - 1) { return true; } prevKeyEndPos = maxKeyEndPos; maxKeyEndPos = Math.max(maxKeyEndPos, property.key.loc.end.column); var keyToken = file.getFirstNodeToken(property.key); if (property.computed === true) { while (keyToken.value !== ']') { keyToken = file.getNextToken(keyToken); } } var colon = file.getNextToken(keyToken); if (prevKeyEndPos < maxKeyEndPos) { minColonPos = colon.loc.start.column; } tokens.push({key: keyToken, colon: colon}); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | node.type === 'SpreadProperty') {··· return true; } |
| ✓ Negative was executed (else) | }··· if (mode === 'ignoreFunction' && property.value.type === 'FunctionExpression') { |
| Branch LogicalExpression | |
| ✓ Was returned | node.type === 'SpreadProperty') { |
| ✓ Was returned | if (property.shorthand || property.method || property.kind !== 'init' || |
| Branch LogicalExpression | |
| ✓ Was returned | if (property.shorthand || property.method || property.kind !== 'init' || |
| ✓ Was returned | if (property.shorthand || property.method || property.kind !== 'init' || |
| Branch LogicalExpression | |
| ✓ Was returned | if (property.shorthand || property.method || property.kind !== 'init' || |
| ✓ Was returned | if (property.shorthand || property.method || property.kind !== 'init' || |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (mode === 'ignoreFunction' && property.value.type === 'FunctionExpression') {··· return true; } |
| ✓ Negative was executed (else) | }··· if (mode === 'ignoreLineBreak' && index > 0 && |
| Branch LogicalExpression | |
| ✓ Was returned | if (mode === 'ignoreFunction' && property.value.type === 'FunctionExpression') { |
| ✓ Was returned | if (mode === 'ignoreFunction' && property.value.type === 'FunctionExpression') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | node.properties[index - 1].loc.end.line !== property.loc.start.line - 1) {··· return true; } |
| ✓ Negative was executed (else) | }··· prevKeyEndPos = maxKeyEndPos; |
| Branch LogicalExpression | |
| ✓ Was returned | node.properties[index - 1].loc.end.line !== property.loc.start.line - 1) { |
| ✓ Was returned | if (mode === 'ignoreLineBreak' && index > 0 && |
| Branch LogicalExpression | |
| ✓ Was returned | if (mode === 'ignoreLineBreak' && index > 0 && |
| ✓ Was returned | if (mode === 'ignoreLineBreak' && index > 0 && |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (property.computed === true) {··· while (keyToken.value !== ']') { keyToken = file.getNextToken(keyToken); } } |
| ✓ Negative was executed (else) | }··· var colon = file.getNextToken(keyToken); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (prevKeyEndPos < maxKeyEndPos) {··· minColonPos = colon.loc.start.column; } |
| ✓ Negative was executed (else) | }··· tokens.push({key: keyToken, colon: colon}); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (skip) {··· return; } |
| ✓ Negative was executed (else) | }··· var space = minColonPos - maxKeyEndPos; |
| Function (anonymous_765) | |
|---|---|
| ✓ Was called | tokens.forEach(function(pair) {··· errors.assert.spacesBetween({ token: pair.key, nextToken: pair.colon, exactly: maxKeyEndPos - pair.key.loc.end.column + space, message: 'Alignment required' }); }); |
| Function (anonymous_766) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_767) | |
|---|---|
| ✓ Was called | configure: function(options) {··· var optionName = this.getOptionName(); if (typeof options === 'object') { assert(Array.isArray(options.allExcept), optionName + ' option requires "allExcept" to be an array'); assert(options.allExcept.length > 0, optionName + ' option requires "allExcept" to have at least one ' + ' item or be set to `true`'); this._exceptDeclarations = options.allExcept.indexOf('declarations') > -1; } else { assert(options === true, this.getOptionName() + ' option requires either a true value or an object'); } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof options === 'object') {··· assert(Array.isArray(options.allExcept), optionName + ' option requires "allExcept" to be an array'); assert(options.allExcept.length > 0, optionName + ' option requires "allExcept" to have at least one ' + ' item or be set to `true`'); this._exceptDeclarations = options.allExcept.indexOf('declarations') > -1; } else { |
| ✓ Negative was executed (else) | } else {··· assert(options === true, this.getOptionName() + ' option requires either a true value or an object'); } |
| Function (anonymous_768) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireAnonymousFunctions'; }, |
| Function (anonymous_769) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var exceptDeclarations = this._exceptDeclarations; file.iterateNodesByType(['FunctionExpression', 'FunctionDeclaration'], function(node) { if (exceptDeclarations && node.type === 'FunctionDeclaration') { return; } if (node.id !== null) { errors.add('Functions must not be named', node.loc.start); } }); } |
| Function (anonymous_770) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['FunctionExpression', 'FunctionDeclaration'], function(node) {··· if (exceptDeclarations && node.type === 'FunctionDeclaration') { return; } if (node.id !== null) { errors.add('Functions must not be named', node.loc.start); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (exceptDeclarations && node.type === 'FunctionDeclaration') {··· return; } |
| ✓ Negative was executed (else) | }··· if (node.id !== null) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (exceptDeclarations && node.type === 'FunctionDeclaration') { |
| ✓ Was returned | if (exceptDeclarations && node.type === 'FunctionDeclaration') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.id !== null) {··· errors.add('Functions must not be named', node.loc.start); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_771) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_772) | |
|---|---|
| ✓ Was called | configure: function(option) {··· assert(option === true, this.getOptionName() + ' requires a true value'); }, |
| Function (anonymous_773) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireArrayDestructuring'; }, |
| Function (anonymous_774) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('VariableDeclaration', function(node) { node.declarations.forEach(function(declaration) { if (!declaration.init || declaration.init.type !== 'MemberExpression') { return; } var property = declaration.init.property || {}; if (property.type === 'Literal' && /^\d+$/.test(property.value)) { errors.add('Use array destructuring', property.loc.start); } }); }); } |
| Function (anonymous_775) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('VariableDeclaration', function(node) {··· node.declarations.forEach(function(declaration) { if (!declaration.init || declaration.init.type !== 'MemberExpression') { return; } var property = declaration.init.property || {}; if (property.type === 'Literal' && /^\d+$/.test(property.value)) { errors.add('Use array destructuring', property.loc.start); } }); }); |
| Function (anonymous_776) | |
|---|---|
| ✓ Was called | node.declarations.forEach(function(declaration) {··· if (!declaration.init || declaration.init.type !== 'MemberExpression') { return; } var property = declaration.init.property || {}; if (property.type === 'Literal' && /^\d+$/.test(property.value)) { errors.add('Use array destructuring', property.loc.start); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!declaration.init || declaration.init.type !== 'MemberExpression') {··· return; } |
| ✓ Negative was executed (else) | }··· var property = declaration.init.property || {}; |
| Branch LogicalExpression | |
| ✓ Was returned | if (!declaration.init || declaration.init.type !== 'MemberExpression') { |
| ✗ Was not returned | if (!declaration.init || declaration.init.type !== 'MemberExpression') { |
| Branch LogicalExpression | |
|---|---|
| ✗ Was not returned | var property = declaration.init.property || {}; |
| ✓ Was returned | var property = declaration.init.property || {}; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (property.type === 'Literal' && /^\d+$/.test(property.value)) {··· errors.add('Use array destructuring', property.loc.start); } |
| ✗ Negative was not executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | if (property.type === 'Literal' && /^\d+$/.test(property.value)) { |
| ✗ Was not returned | if (property.type === 'Literal' && /^\d+$/.test(property.value)) { |
| Function (anonymous_777) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_778) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_779) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireArrowFunctions'; }, |
| Function (anonymous_780) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· function isCallback(node) { return node.type === 'FunctionExpression' && node.parentNode.type === 'CallExpression'; } function isFunctionBindWithThis(node) { return node.callee && node.callee.type === 'MemberExpression' && node.callee.object.type === 'FunctionExpression' && node.callee.property.type === 'Identifier' && node.callee.property.name === 'bind' && node.arguments && node.arguments.length === 1 && node.arguments[0].type === 'ThisExpression'; } file.iterateNodesByType(['FunctionExpression', 'CallExpression'], function(node) { if (isCallback(node) || isFunctionBindWithThis(node)) { errors.add('Use arrow functions instead of function expressions', node.loc.start); } }); } |
| Function isCallback | |
|---|---|
| ✓ Was called | function isCallback(node) {··· return node.type === 'FunctionExpression' && node.parentNode.type === 'CallExpression'; } |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | return node.type === 'FunctionExpression' && node.parentNode.type === 'CallExpression'; |
| ✓ Was returned | return node.type === 'FunctionExpression' && node.parentNode.type === 'CallExpression'; |
| Function isFunctionBindWithThis | |
|---|---|
| ✓ Was called | function isFunctionBindWithThis(node) {··· return node.callee && node.callee.type === 'MemberExpression' && node.callee.object.type === 'FunctionExpression' && node.callee.property.type === 'Identifier' && node.callee.property.name === 'bind' && node.arguments && node.arguments.length === 1 && node.arguments[0].type === 'ThisExpression'; } |
| Branch LogicalExpression | |
|---|---|
| ✗ Was not returned | node.arguments.length === 1 && node.arguments[0].type === 'ThisExpression'; |
| ✓ Was returned | return node.callee &&··· node.callee.type === 'MemberExpression' && node.callee.object.type === 'FunctionExpression' && node.callee.property.type === 'Identifier' && node.callee.property.name === 'bind' && node.arguments && node.arguments.length === 1 && node.arguments[0].type === 'ThisExpression'; |
| Branch LogicalExpression | |
| ✗ Was not returned | node.arguments.length === 1 && node.arguments[0].type === 'ThisExpression'; |
| ✓ Was returned | return node.callee &&··· node.callee.type === 'MemberExpression' && node.callee.object.type === 'FunctionExpression' && node.callee.property.type === 'Identifier' && node.callee.property.name === 'bind' && node.arguments && |
| Branch LogicalExpression | |
| ✗ Was not returned | node.arguments && |
| ✓ Was returned | return node.callee &&··· node.callee.type === 'MemberExpression' && node.callee.object.type === 'FunctionExpression' && node.callee.property.type === 'Identifier' && node.callee.property.name === 'bind' && |
| Branch LogicalExpression | |
| ✗ Was not returned | node.callee.property.name === 'bind' && |
| ✓ Was returned | return node.callee &&··· node.callee.type === 'MemberExpression' && node.callee.object.type === 'FunctionExpression' && node.callee.property.type === 'Identifier' && |
| Branch LogicalExpression | |
| ✗ Was not returned | node.callee.property.type === 'Identifier' && |
| ✓ Was returned | return node.callee &&··· node.callee.type === 'MemberExpression' && node.callee.object.type === 'FunctionExpression' && |
| Branch LogicalExpression | |
| ✓ Was returned | node.callee.object.type === 'FunctionExpression' && |
| ✓ Was returned | return node.callee &&··· node.callee.type === 'MemberExpression' && |
| Branch LogicalExpression | |
| ✓ Was returned | node.callee.type === 'MemberExpression' && |
| ✓ Was returned | return node.callee && |
| Function (anonymous_783) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['FunctionExpression', 'CallExpression'], function(node) {··· if (isCallback(node) || isFunctionBindWithThis(node)) { errors.add('Use arrow functions instead of function expressions', node.loc.start); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isCallback(node) || isFunctionBindWithThis(node)) {··· errors.add('Use arrow functions instead of function expressions', node.loc.start); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | if (isCallback(node) || isFunctionBindWithThis(node)) { |
| ✓ Was returned | if (isCallback(node) || isFunctionBindWithThis(node)) { |
| Function hasCommentInBlock | |
|---|---|
| ✓ Was called | function hasCommentInBlock(block, commentTokens) {··· var count; var comment; for (count = 0; count < commentTokens.length; count++) { comment = commentTokens[count]; if (comment.range[0] >= block.range[0] && comment.range[1] <= block.range[1]) { return true; } } return false; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | comment.range[1] <= block.range[1]) {··· return true; } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | comment.range[1] <= block.range[1]) { |
| ✓ Was returned | if (comment.range[0] >= block.range[0] && |
| Function (anonymous_785) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_786) | |
|---|---|
| ✓ Was called | configure: function(options) {··· var optionType = typeof options; assert( options === true || optionType === 'number' || optionType === 'object', this.getOptionName() + ' option requires the value true, an Integer or an object' ); this._minLines = 0; this._includeComments = false; if (optionType === 'number') { this._minLines = options; } else if (optionType === 'object') { assert( options.includeComments === true, this.getOptionName() + ' option requires includeComments property to be true for object' ); this._includeComments = options.includeComments; if (options.hasOwnProperty('minLines')) { assert( typeof options.minLines === 'number', this.getOptionName() + ' option requires minLines property to be an integer for object' ); this._minLines = options.minLines; } } assert( this._minLines >= 0, this.getOptionName() + ' option requires minimum statements setting to be >= 0' ); }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options === true || optionType === 'number' || optionType === 'object', |
| ✓ Was returned | options === true || optionType === 'number' || optionType === 'object', |
| Branch LogicalExpression | |
| ✓ Was returned | options === true || optionType === 'number' || optionType === 'object', |
| ✓ Was returned | options === true || optionType === 'number' || optionType === 'object', |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (optionType === 'number') {··· this._minLines = options; } else if (optionType === 'object') { |
| ✓ Negative was executed (else) | } else if (optionType === 'object') {··· assert( options.includeComments === true, this.getOptionName() + ' option requires includeComments property to be true for object' ); this._includeComments = options.includeComments; if (options.hasOwnProperty('minLines')) { assert( typeof options.minLines === 'number', this.getOptionName() + ' option requires minLines property to be an integer for object' ); this._minLines = options.minLines; } } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (optionType === 'object') {··· assert( options.includeComments === true, this.getOptionName() + ' option requires includeComments property to be true for object' ); this._includeComments = options.includeComments; if (options.hasOwnProperty('minLines')) { assert( typeof options.minLines === 'number', this.getOptionName() + ' option requires minLines property to be an integer for object' ); this._minLines = options.minLines; } } |
| ✓ Negative was executed (else) | }··· assert( |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options.hasOwnProperty('minLines')) {··· assert( typeof options.minLines === 'number', this.getOptionName() + ' option requires minLines property to be an integer for object' ); this._minLines = options.minLines; } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_787) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireBlocksOnNewline'; }, |
| Function (anonymous_788) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var minLines = this._minLines; var includeComments = this._includeComments; var commentTokens = []; file.iterateTokensByType(['Line', 'Block'], function(commentToken) { commentTokens.push(commentToken); }); file.iterateNodesByType('BlockStatement', function(node) { var hasComment = false; if (includeComments === true) { hasComment = hasCommentInBlock(node, commentTokens); } if (hasComment === false && node.body.length <= minLines) { return; } var openingBracket = file.getFirstNodeToken(node); var nextToken = file.getNextToken(openingBracket, { includeComments: includeComments }); errors.assert.differentLine({ token: openingBracket, nextToken: nextToken, message: 'Missing newline after opening curly brace' }); var closingBracket = file.getLastNodeToken(node); var prevToken = file.getPrevToken(closingBracket, { includeComments: includeComments }); errors.assert.differentLine({ token: prevToken, nextToken: closingBracket, message: 'Missing newline before closing curly brace' }); }); } |
| Function (anonymous_789) | |
|---|---|
| ✓ Was called | file.iterateTokensByType(['Line', 'Block'], function(commentToken) {··· commentTokens.push(commentToken); }); |
| Function (anonymous_790) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('BlockStatement', function(node) {··· var hasComment = false; if (includeComments === true) { hasComment = hasCommentInBlock(node, commentTokens); } if (hasComment === false && node.body.length <= minLines) { return; } var openingBracket = file.getFirstNodeToken(node); var nextToken = file.getNextToken(openingBracket, { includeComments: includeComments }); errors.assert.differentLine({ token: openingBracket, nextToken: nextToken, message: 'Missing newline after opening curly brace' }); var closingBracket = file.getLastNodeToken(node); var prevToken = file.getPrevToken(closingBracket, { includeComments: includeComments }); errors.assert.differentLine({ token: prevToken, nextToken: closingBracket, message: 'Missing newline before closing curly brace' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (includeComments === true) {··· hasComment = hasCommentInBlock(node, commentTokens); } |
| ✓ Negative was executed (else) | }··· if (hasComment === false && node.body.length <= minLines) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (hasComment === false && node.body.length <= minLines) {··· return; } |
| ✓ Negative was executed (else) | }··· var openingBracket = file.getFirstNodeToken(node); |
| Branch LogicalExpression | |
| ✓ Was returned | if (hasComment === false && node.body.length <= minLines) { |
| ✓ Was returned | if (hasComment === false && node.body.length <= minLines) { |
| Function processArrayOfStringOrRegExp | |
|---|---|
| ✓ Was called | function processArrayOfStringOrRegExp(iv) {··· if (!Array.isArray(iv)) { return; } var rv = []; var i = 0; while (rv && (i < iv.length)) { var elt = iv[i]; if (typeof elt === 'string') { // string values OK rv.push(elt); } else if (elt instanceof RegExp) { // existing RegExp OK rv.push(elt); } else if (elt && (typeof elt === 'object')) { try { // ESTree RegExpLiteral ok if it produces RegExp rv.push(new RegExp(elt.regex.pattern, elt.regex.flags || '')); } catch (e) { // Not a valid RegExpLiteral rv = null; } } else { // Unknown value rv = null; } ++i; } return rv; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!Array.isArray(iv)) {··· return; } |
| ✓ Negative was executed (else) | }··· var rv = []; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | while (rv && (i < iv.length)) { |
| ✓ Was returned | while (rv && (i < iv.length)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof elt === 'string') {··· // string values OK rv.push(elt); } else if (elt instanceof RegExp) { |
| ✓ Negative was executed (else) | } else if (elt instanceof RegExp) {··· // existing RegExp OK rv.push(elt); } else if (elt && (typeof elt === 'object')) { try { // ESTree RegExpLiteral ok if it produces RegExp rv.push(new RegExp(elt.regex.pattern, elt.regex.flags || '')); } catch (e) { // Not a valid RegExpLiteral rv = null; } } else { // Unknown value rv = null; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (elt instanceof RegExp) {··· // existing RegExp OK rv.push(elt); } else if (elt && (typeof elt === 'object')) { |
| ✓ Negative was executed (else) | } else if (elt && (typeof elt === 'object')) {··· try { // ESTree RegExpLiteral ok if it produces RegExp rv.push(new RegExp(elt.regex.pattern, elt.regex.flags || '')); } catch (e) { // Not a valid RegExpLiteral rv = null; } } else { // Unknown value rv = null; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (elt && (typeof elt === 'object')) {··· try { // ESTree RegExpLiteral ok if it produces RegExp rv.push(new RegExp(elt.regex.pattern, elt.regex.flags || '')); } catch (e) { // Not a valid RegExpLiteral rv = null; } } else { |
| ✓ Negative was executed (else) | } else {··· // Unknown value rv = null; } |
| Branch LogicalExpression | |
| ✓ Was returned | } else if (elt && (typeof elt === 'object')) { |
| ✓ Was returned | } else if (elt && (typeof elt === 'object')) { |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | rv.push(new RegExp(elt.regex.pattern, elt.regex.flags || '')); |
| ✓ Was returned | rv.push(new RegExp(elt.regex.pattern, elt.regex.flags || '')); |
| Function startAfterStringPrefix | |
|---|---|
| ✓ Was called | function startAfterStringPrefix(value, prefix) {··· var start = prefix.length; if (start >= value.length) { return; } if (value.substr(0, prefix.length) !== prefix) { return; } return start; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (start >= value.length) {··· return; } |
| ✓ Negative was executed (else) | }··· if (value.substr(0, prefix.length) !== prefix) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value.substr(0, prefix.length) !== prefix) {··· return; } |
| ✓ Negative was executed (else) | }··· return start; |
| Function startAfterRegExpPrefix | |
|---|---|
| ✓ Was called | function startAfterRegExpPrefix(value, prefix) {··· var match = prefix.exec(value); if (!match) { return; } if (match.index !== 0) { return; } return match[0].length; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!match) {··· return; } |
| ✓ Negative was executed (else) | }··· if (match.index !== 0) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (match.index !== 0) {··· return; } |
| ✓ Negative was executed (else) | }··· return match[0].length; |
| Function endBeforeStringSuffix | |
|---|---|
| ✓ Was called | function endBeforeStringSuffix(value, suffix) {··· var ends = value.length - suffix.length; if (ends <= 0) { return; } if (value.substr(ends) !== suffix) { return; } return ends; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (ends <= 0) {··· return; } |
| ✓ Negative was executed (else) | }··· if (value.substr(ends) !== suffix) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value.substr(ends) !== suffix) {··· return; } |
| ✓ Negative was executed (else) | }··· return ends; |
| Function endBeforeRegExpSuffix | |
|---|---|
| ✓ Was called | function endBeforeRegExpSuffix(value, suffix) {··· var match = suffix.exec(value); if (!match) { return; } var ends = match.index; if ((ends + match[0].length) !== value.length) { return; } return ends; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!match) {··· return; } |
| ✓ Negative was executed (else) | }··· var ends = match.index; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ((ends + match[0].length) !== value.length) {··· return; } |
| ✓ Negative was executed (else) | }··· return ends; |
| Function matchException | |
|---|---|
| ✓ Was called | function matchException(value, exception) {··· if (typeof exception === 'string') { return (exception === value); } return exception.test(value); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof exception === 'string') {··· return (exception === value); } |
| ✓ Negative was executed (else) | }··· return exception.test(value); |
| Function (anonymous_797) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_798) | |
|---|---|
| ✓ Was called | configure: function(options) {··· if (typeof options !== 'object') { assert( options === true || options === 'ignoreProperties', this.getOptionName() + ' option requires a true value or `ignoreProperties`' ); var _options = { ignoreProperties: options === 'ignoreProperties' ? true : false, strict: false }; return this.configure(_options); } assert( !options.hasOwnProperty('ignoreProperties') || typeof options.ignoreProperties === 'boolean', this.getOptionName() + ' option should have boolean value for ignoreProperties' ); this._ignoreProperties = options.ignoreProperties; assert( !options.hasOwnProperty('strict') || typeof options.strict === 'boolean', this.getOptionName() + ' option should have boolean value for strict' ); this._strict = options.strict; var asre = processArrayOfStringOrRegExp(options.allowedPrefixes); assert( !options.hasOwnProperty('allowedPrefixes') || asre, this.getOptionName() + ' option should have array of string or RegExp for allowedPrefixes' ); if (asre) { this._allowedPrefixes = asre; } asre = processArrayOfStringOrRegExp(options.allowedSuffixes); assert( !options.hasOwnProperty('allowedSuffixes') || asre, this.getOptionName() + ' option should have array of string or RegExp for allowedSuffixes' ); if (asre) { this._allowedSuffixes = asre; } asre = processArrayOfStringOrRegExp(options.allExcept); assert( !options.hasOwnProperty('allExcept') || asre, this.getOptionName() + ' option should have array of string or RegExp for allExcept' ); if (asre) { this._allExcept = asre; } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof options !== 'object') {··· assert( options === true || options === 'ignoreProperties', this.getOptionName() + ' option requires a true value or `ignoreProperties`' ); var _options = { ignoreProperties: options === 'ignoreProperties' ? true : false, strict: false }; return this.configure(_options); } |
| ✓ Negative was executed (else) | }··· assert( |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options === true || options === 'ignoreProperties', |
| ✓ Was returned | options === true || options === 'ignoreProperties', |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | ignoreProperties: options === 'ignoreProperties' ? true : false, |
| ✓ Negative was returned (: ...) | ignoreProperties: options === 'ignoreProperties' ? true : false, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | !options.hasOwnProperty('ignoreProperties') || typeof options.ignoreProperties === 'boolean', |
| ✓ Was returned | !options.hasOwnProperty('ignoreProperties') || typeof options.ignoreProperties === 'boolean', |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | !options.hasOwnProperty('strict') || typeof options.strict === 'boolean', |
| ✓ Was returned | !options.hasOwnProperty('strict') || typeof options.strict === 'boolean', |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | !options.hasOwnProperty('allowedPrefixes') || asre, |
| ✓ Was returned | !options.hasOwnProperty('allowedPrefixes') || asre, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (asre) {··· this._allowedPrefixes = asre; } |
| ✓ Negative was executed (else) | }··· asre = processArrayOfStringOrRegExp(options.allowedSuffixes); |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | !options.hasOwnProperty('allowedSuffixes') || asre, |
| ✓ Was returned | !options.hasOwnProperty('allowedSuffixes') || asre, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (asre) {··· this._allowedSuffixes = asre; } |
| ✓ Negative was executed (else) | }··· asre = processArrayOfStringOrRegExp(options.allExcept); |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | !options.hasOwnProperty('allExcept') || asre, |
| ✓ Was returned | !options.hasOwnProperty('allExcept') || asre, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (asre) {··· this._allExcept = asre; } |
| ✓ Negative was executed (else) | }··· }, |
| Function (anonymous_799) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireCamelCaseOrUpperCaseIdentifiers'; }, |
| Function (anonymous_800) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateTokensByType('Identifier', function(token) { var value = token.value; // Leading and trailing underscores signify visibility/scope and do not affect // validation of the rule. Remove them to simplify the checks. var isPrivate = (value[0] === '_'); value = value.replace(/^_+|_+$/g, ''); // Detect exceptions before stripping prefixes/suffixes. if (this._allExcept) { for (i = 0, len = this._allExcept.length; i < len; ++i) { if (matchException(value, this._allExcept[i])) { return; } } } // Strip at most one prefix permitted text from the identifier. This transformation // cannot change an acceptable identifier into an unacceptable identifier so we can // continue with the normal verification of whatever it produces. var i; var len; if (this._allowedPrefixes) { for (i = 0, len = this._allowedPrefixes.length; i < len; ++i) { var prefix = this._allowedPrefixes[i]; var start; if (typeof prefix === 'string') { start = startAfterStringPrefix(value, prefix); } else { start = startAfterRegExpPrefix(value, prefix); } if (start !== undefined) { value = value.substr(start); break; } } } // As with prefix but for one suffix permitted text. if (this._allowedSuffixes) { for (i = 0, len = this._allowedSuffixes.length; i < len; ++i) { var suffix = this._allowedSuffixes[i]; var ends; if (typeof suffix === 'string') { ends = endBeforeStringSuffix(value, suffix); } else { ends = endBeforeRegExpSuffix(value, suffix); } if (ends !== undefined) { value = value.substr(0, ends); break; } } } if (value.indexOf('_') === -1 || value.toUpperCase() === value) { if (!this._strict) {return;} if (value.length === 0 || value[0].toUpperCase() !== value[0] || isPrivate) { return; } } if (this._ignoreProperties) { var nextToken = file.getNextToken(token); var prevToken = file.getPrevToken(token); if (nextToken && nextToken.value === ':') { return; } /* This enables an identifier to be snake cased via the object * destructuring pattern. We must check to see if the identifier * is being used to set values into an object to determine if * this is a legal assignment. * Example: ({camelCase: snake_case}) => camelCase.length */ if (prevToken && prevToken.value === ':') { var node = file.getNodeByRange(token.range[0]); var parentNode = node.parentNode; if (parentNode && parentNode.type === 'Property') { var grandpa = parentNode.parentNode; if (grandpa && grandpa.type === 'ObjectPattern') { return; } } } if (prevToken && (prevToken.value === '.' || prevToken.value === 'get' || prevToken.value === 'set')) { return; } } errors.add( 'All identifiers must be camelCase or UPPER_CASE', token.loc.start.line, token.loc.start.column ); }.bind(this)); } |
| Function (anonymous_801) | |
|---|---|
| ✓ Was called | file.iterateTokensByType('Identifier', function(token) {··· var value = token.value; // Leading and trailing underscores signify visibility/scope and do not affect // validation of the rule. Remove them to simplify the checks. var isPrivate = (value[0] === '_'); value = value.replace(/^_+|_+$/g, ''); // Detect exceptions before stripping prefixes/suffixes. if (this._allExcept) { for (i = 0, len = this._allExcept.length; i < len; ++i) { if (matchException(value, this._allExcept[i])) { return; } } } // Strip at most one prefix permitted text from the identifier. This transformation // cannot change an acceptable identifier into an unacceptable identifier so we can // continue with the normal verification of whatever it produces. var i; var len; if (this._allowedPrefixes) { for (i = 0, len = this._allowedPrefixes.length; i < len; ++i) { var prefix = this._allowedPrefixes[i]; var start; if (typeof prefix === 'string') { start = startAfterStringPrefix(value, prefix); } else { start = startAfterRegExpPrefix(value, prefix); } if (start !== undefined) { value = value.substr(start); break; } } } // As with prefix but for one suffix permitted text. if (this._allowedSuffixes) { for (i = 0, len = this._allowedSuffixes.length; i < len; ++i) { var suffix = this._allowedSuffixes[i]; var ends; if (typeof suffix === 'string') { ends = endBeforeStringSuffix(value, suffix); } else { ends = endBeforeRegExpSuffix(value, suffix); } if (ends !== undefined) { value = value.substr(0, ends); break; } } } if (value.indexOf('_') === -1 || value.toUpperCase() === value) { if (!this._strict) {return;} if (value.length === 0 || value[0].toUpperCase() !== value[0] || isPrivate) { return; } } if (this._ignoreProperties) { var nextToken = file.getNextToken(token); var prevToken = file.getPrevToken(token); if (nextToken && nextToken.value === ':') { return; } /* This enables an identifier to be snake cased via the object * destructuring pattern. We must check to see if the identifier * is being used to set values into an object to determine if * this is a legal assignment. * Example: ({camelCase: snake_case}) => camelCase.length */ if (prevToken && prevToken.value === ':') { var node = file.getNodeByRange(token.range[0]); var parentNode = node.parentNode; if (parentNode && parentNode.type === 'Property') { var grandpa = parentNode.parentNode; if (grandpa && grandpa.type === 'ObjectPattern') { return; } } } if (prevToken && (prevToken.value === '.' || prevToken.value === 'get' || prevToken.value === 'set')) { return; } } errors.add( 'All identifiers must be camelCase or UPPER_CASE', token.loc.start.line, token.loc.start.column ); }.bind(this)); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._allExcept) {··· for (i = 0, len = this._allExcept.length; i < len; ++i) { if (matchException(value, this._allExcept[i])) { return; } } } |
| ✓ Negative was executed (else) | }··· // Strip at most one prefix permitted text from the identifier. This transformation |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (matchException(value, this._allExcept[i])) {··· return; } |
| ✓ Negative was executed (else) | }··· } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._allowedPrefixes) {··· for (i = 0, len = this._allowedPrefixes.length; i < len; ++i) { var prefix = this._allowedPrefixes[i]; var start; if (typeof prefix === 'string') { start = startAfterStringPrefix(value, prefix); } else { start = startAfterRegExpPrefix(value, prefix); } if (start !== undefined) { value = value.substr(start); break; } } } |
| ✓ Negative was executed (else) | }··· // As with prefix but for one suffix permitted text. |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof prefix === 'string') {··· start = startAfterStringPrefix(value, prefix); } else { |
| ✓ Negative was executed (else) | } else {··· start = startAfterRegExpPrefix(value, prefix); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (start !== undefined) {··· value = value.substr(start); break; } |
| ✓ Negative was executed (else) | }··· } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._allowedSuffixes) {··· for (i = 0, len = this._allowedSuffixes.length; i < len; ++i) { var suffix = this._allowedSuffixes[i]; var ends; if (typeof suffix === 'string') { ends = endBeforeStringSuffix(value, suffix); } else { ends = endBeforeRegExpSuffix(value, suffix); } if (ends !== undefined) { value = value.substr(0, ends); break; } } } |
| ✓ Negative was executed (else) | }··· if (value.indexOf('_') === -1 || value.toUpperCase() === value) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof suffix === 'string') {··· ends = endBeforeStringSuffix(value, suffix); } else { |
| ✓ Negative was executed (else) | } else {··· ends = endBeforeRegExpSuffix(value, suffix); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (ends !== undefined) {··· value = value.substr(0, ends); break; } |
| ✓ Negative was executed (else) | }··· } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value.indexOf('_') === -1 || value.toUpperCase() === value) {··· if (!this._strict) {return;} if (value.length === 0 || value[0].toUpperCase() !== value[0] || isPrivate) { return; } } |
| ✓ Negative was executed (else) | }··· if (this._ignoreProperties) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (value.indexOf('_') === -1 || value.toUpperCase() === value) { |
| ✓ Was returned | if (value.indexOf('_') === -1 || value.toUpperCase() === value) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!this._strict) {return;} |
| ✓ Negative was executed (else) | if (!this._strict) {return;}··· if (value.length === 0 || value[0].toUpperCase() !== value[0] || isPrivate) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value.length === 0 || value[0].toUpperCase() !== value[0] || isPrivate) {··· return; } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | if (value.length === 0 || value[0].toUpperCase() !== value[0] || isPrivate) { |
| ✓ Was returned | if (value.length === 0 || value[0].toUpperCase() !== value[0] || isPrivate) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (value.length === 0 || value[0].toUpperCase() !== value[0] || isPrivate) { |
| ✓ Was returned | if (value.length === 0 || value[0].toUpperCase() !== value[0] || isPrivate) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._ignoreProperties) {··· var nextToken = file.getNextToken(token); var prevToken = file.getPrevToken(token); if (nextToken && nextToken.value === ':') { return; } /* This enables an identifier to be snake cased via the object * destructuring pattern. We must check to see if the identifier * is being used to set values into an object to determine if * this is a legal assignment. * Example: ({camelCase: snake_case}) => camelCase.length */ if (prevToken && prevToken.value === ':') { var node = file.getNodeByRange(token.range[0]); var parentNode = node.parentNode; if (parentNode && parentNode.type === 'Property') { var grandpa = parentNode.parentNode; if (grandpa && grandpa.type === 'ObjectPattern') { return; } } } if (prevToken && (prevToken.value === '.' || prevToken.value === 'get' || prevToken.value === 'set')) { return; } } |
| ✓ Negative was executed (else) | }··· errors.add( |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (nextToken && nextToken.value === ':') {··· return; } |
| ✓ Negative was executed (else) | }··· /* This enables an identifier to be snake cased via the object |
| Branch LogicalExpression | |
| ✓ Was returned | if (nextToken && nextToken.value === ':') { |
| ✗ Was not returned | if (nextToken && nextToken.value === ':') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (prevToken && prevToken.value === ':') {··· var node = file.getNodeByRange(token.range[0]); var parentNode = node.parentNode; if (parentNode && parentNode.type === 'Property') { var grandpa = parentNode.parentNode; if (grandpa && grandpa.type === 'ObjectPattern') { return; } } } |
| ✓ Negative was executed (else) | }··· if (prevToken && (prevToken.value === '.' || |
| Branch LogicalExpression | |
| ✓ Was returned | if (prevToken && prevToken.value === ':') { |
| ✓ Was returned | if (prevToken && prevToken.value === ':') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (parentNode && parentNode.type === 'Property') {··· var grandpa = parentNode.parentNode; if (grandpa && grandpa.type === 'ObjectPattern') { return; } } |
| ✗ Negative was not executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | if (parentNode && parentNode.type === 'Property') { |
| ✗ Was not returned | if (parentNode && parentNode.type === 'Property') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (grandpa && grandpa.type === 'ObjectPattern') {··· return; } |
| ✗ Negative was not executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | if (grandpa && grandpa.type === 'ObjectPattern') { |
| ✗ Was not returned | if (grandpa && grandpa.type === 'ObjectPattern') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | prevToken.value === 'get' || prevToken.value === 'set')) {··· return; } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | if (prevToken && (prevToken.value === '.' ||··· prevToken.value === 'get' || prevToken.value === 'set')) { |
| ✓ Was returned | if (prevToken && (prevToken.value === '.' || |
| Branch LogicalExpression | |
| ✓ Was returned | prevToken.value === 'get' || prevToken.value === 'set')) { |
| ✓ Was returned | if (prevToken && (prevToken.value === '.' ||··· prevToken.value === 'get' || prevToken.value === 'set')) { |
| Branch LogicalExpression | |
| ✓ Was returned | prevToken.value === 'get' || prevToken.value === 'set')) { |
| ✓ Was returned | if (prevToken && (prevToken.value === '.' || |
| Function (anonymous_802) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_803) | |
|---|---|
| ✓ Was called | configure: function(options) {··· var exceptions; this.inlined = false; this._isPragma = null; var optionName = this.getOptionName(); var isObject = typeof options === 'object'; var error = optionName + ' option requires a true value ' + 'or an object with String[] `allExcept` property or true with `inlined`'; assert( options === true || isObject, error ); if (isObject && options.allExcept) { exceptions = options.allExcept; // verify items in `allExcept` property in object are string values assert( Array.isArray(exceptions) && exceptions.every(function(el) { return typeof el === 'string'; }), 'Property `allExcept` in ' + optionName + ' should be an array of strings' ); this._isPragma = isPragma(exceptions); } if (!this._isPragma) { this._isPragma = isPragma(); } if (isObject && options.inlined) { this.inlined = true; } if (isObject && !options.allExcept && !options.inlined) { assert(false, error); } }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | isObject, |
| ✓ Was returned | options === true || |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isObject && options.allExcept) {··· exceptions = options.allExcept; // verify items in `allExcept` property in object are string values assert( Array.isArray(exceptions) && exceptions.every(function(el) { return typeof el === 'string'; }), 'Property `allExcept` in ' + optionName + ' should be an array of strings' ); this._isPragma = isPragma(exceptions); } |
| ✓ Negative was executed (else) | }··· if (!this._isPragma) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (isObject && options.allExcept) { |
| ✓ Was returned | if (isObject && options.allExcept) { |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | exceptions.every(function(el) { return typeof el === 'string'; }), |
| ✗ Was not returned | Array.isArray(exceptions) && |
| Function (anonymous_804) | |
|---|---|
| ✓ Was called | exceptions.every(function(el) { return typeof el === 'string'; }), |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!this._isPragma) {··· this._isPragma = isPragma(); } |
| ✓ Negative was executed (else) | }··· if (isObject && options.inlined) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isObject && options.inlined) {··· this.inlined = true; } |
| ✓ Negative was executed (else) | }··· if (isObject && !options.allExcept && !options.inlined) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (isObject && options.inlined) { |
| ✓ Was returned | if (isObject && options.inlined) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isObject && !options.allExcept && !options.inlined) {··· assert(false, error); } |
| ✓ Negative was executed (else) | }··· }, |
| Branch LogicalExpression | |
| ✓ Was returned | if (isObject && !options.allExcept && !options.inlined) { |
| ✓ Was returned | if (isObject && !options.allExcept && !options.inlined) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (isObject && !options.allExcept && !options.inlined) { |
| ✓ Was returned | if (isObject && !options.allExcept && !options.inlined) { |
| Function (anonymous_805) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireCapitalizedComments'; }, |
| Function (anonymous_806) | |
|---|---|
| ✓ Was called | _isUrl: function(comment) {··· var protocolParts = comment.value.split('://'); if (protocolParts.length === 1) { return false; } return comment.value.indexOf(protocolParts[0]) === 0; }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (protocolParts.length === 1) {··· return false; } |
| ✓ Negative was executed (else) | }··· return comment.value.indexOf(protocolParts[0]) === 0; |
| Function (anonymous_807) | |
|---|---|
| ✓ Was called | _isException: function(comment) {··· return this._isPragma(comment.value); }, |
| Function (anonymous_808) | |
|---|---|
| ✓ Was called | _isValid: function(comment) {··· var first = this._getFirstChar(comment); return first && upperCasePattern.test(first); }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | return first && upperCasePattern.test(first); |
| ✗ Was not returned | return first && upperCasePattern.test(first); |
| Function (anonymous_809) | |
|---|---|
| ✓ Was called | _isLetter: function(comment) {··· var first = this._getFirstChar(comment); return first && letterPattern.test(first); }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | return first && letterPattern.test(first); |
| ✓ Was returned | return first && letterPattern.test(first); |
| Function (anonymous_810) | |
|---|---|
| ✓ Was called | _getFirstChar: function(comment) {··· return comment.value.replace(/[\n\s\*]/g, '')[0]; }, |
| Function (anonymous_811) | |
|---|---|
| ✓ Was called | _isTextBlock: function(comment, file) {··· var prevComment = file.getPrevToken(comment, {includeComments: true}); if (prevComment) { return prevComment.type === 'Line' && prevComment.loc.start.line + 1 === comment.loc.start.line && prevComment.value.trim().length > 0; } return false; }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (prevComment) {··· return prevComment.type === 'Line' && prevComment.loc.start.line + 1 === comment.loc.start.line && prevComment.value.trim().length > 0; } |
| ✓ Negative was executed (else) | }··· return false; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | prevComment.value.trim().length > 0; |
| ✓ Was returned | return prevComment.type === 'Line' &&··· prevComment.loc.start.line + 1 === comment.loc.start.line && |
| Branch LogicalExpression | |
| ✓ Was returned | prevComment.loc.start.line + 1 === comment.loc.start.line && |
| ✓ Was returned | return prevComment.type === 'Line' && |
| Function (anonymous_812) | |
|---|---|
| ✓ Was called | _shouldIgnoreIfInTheMiddle: function(file, comment) {··· if (!this.inlined) { return false; } var firstToken = file.getFirstNodeToken(comment); var otherToken = file.getPrevToken(firstToken, { includeComments: true }); return otherToken ? otherToken.loc.start.line === firstToken.loc.start.line : false; }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!this.inlined) {··· return false; } |
| ✓ Negative was executed (else) | }··· var firstToken = file.getFirstNodeToken(comment); |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | return otherToken ? otherToken.loc.start.line === firstToken.loc.start.line : false; |
| ✓ Negative was returned (: ...) | return otherToken ? otherToken.loc.start.line === firstToken.loc.start.line : false; |
| Function (anonymous_813) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var _this = this; function add(comment) { errors.cast({ message: 'Comments must start with an uppercase letter, unless it is part of a textblock', line: comment.loc.start.line, column: comment.loc.start.column, additional: comment }); } file.iterateTokensByType('Line', function(comment) { if (_this._isException(comment)) { return; } if (_this._isUrl(comment)) { return; } if (!_this._isLetter(comment)) { return; } if (_this._isTextBlock(comment, file)) { return; } if (_this._isValid(comment)) { return; } add(comment); }); file.iterateTokensByType('Block', function(comment) { if (_this._isException(comment)) { return; } if (_this._isUrl(comment)) { return; } if (!_this._isLetter(comment)) { return; } if (_this._shouldIgnoreIfInTheMiddle(file, comment)) { return; } if (_this._isValid(comment)) { return; } add(comment); }); }, |
| Function add | |
|---|---|
| ✓ Was called | function add(comment) {··· errors.cast({ message: 'Comments must start with an uppercase letter, unless it is part of a textblock', line: comment.loc.start.line, column: comment.loc.start.column, additional: comment }); } |
| Function (anonymous_815) | |
|---|---|
| ✓ Was called | file.iterateTokensByType('Line', function(comment) {··· if (_this._isException(comment)) { return; } if (_this._isUrl(comment)) { return; } if (!_this._isLetter(comment)) { return; } if (_this._isTextBlock(comment, file)) { return; } if (_this._isValid(comment)) { return; } add(comment); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (_this._isException(comment)) {··· return; } |
| ✓ Negative was executed (else) | }··· if (_this._isUrl(comment)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (_this._isUrl(comment)) {··· return; } |
| ✓ Negative was executed (else) | }··· if (!_this._isLetter(comment)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!_this._isLetter(comment)) {··· return; } |
| ✓ Negative was executed (else) | }··· if (_this._isTextBlock(comment, file)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (_this._isTextBlock(comment, file)) {··· return; } |
| ✓ Negative was executed (else) | }··· if (_this._isValid(comment)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (_this._isValid(comment)) {··· return; } |
| ✓ Negative was executed (else) | }··· add(comment); |
| Function (anonymous_816) | |
|---|---|
| ✓ Was called | file.iterateTokensByType('Block', function(comment) {··· if (_this._isException(comment)) { return; } if (_this._isUrl(comment)) { return; } if (!_this._isLetter(comment)) { return; } if (_this._shouldIgnoreIfInTheMiddle(file, comment)) { return; } if (_this._isValid(comment)) { return; } add(comment); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (_this._isException(comment)) {··· return; } |
| ✓ Negative was executed (else) | }··· if (_this._isUrl(comment)) { |
| Branch IfStatement | |
|---|---|
| ✗ Positive was not executed (if) | if (_this._isUrl(comment)) {··· return; } |
| ✓ Negative was executed (else) | }··· if (!_this._isLetter(comment)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!_this._isLetter(comment)) {··· return; } |
| ✓ Negative was executed (else) | }··· if (_this._shouldIgnoreIfInTheMiddle(file, comment)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (_this._shouldIgnoreIfInTheMiddle(file, comment)) {··· return; } |
| ✓ Negative was executed (else) | }··· if (_this._isValid(comment)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (_this._isValid(comment)) {··· return; } |
| ✓ Negative was executed (else) | }··· add(comment); |
| Function (anonymous_817) | |
|---|---|
| ✓ Was called | _fix: function(file, error) {··· var comment = error.additional; var first = this._getFirstChar(comment); comment.value = comment.value.replace(first, first.toUpperCase()); } |
| Function (anonymous_818) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_819) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true || Array.isArray(options.allExcept), this.getOptionName() + ' option requires a true value or an object of exceptions' ); this._allowedConstructors = {}; var allExcept = options.allExcept; if (allExcept) { for (var i = 0, l = allExcept.length; i < l; i++) { this._allowedConstructors[allExcept[i]] = true; } } }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options === true || Array.isArray(options.allExcept), |
| ✓ Was returned | options === true || Array.isArray(options.allExcept), |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (allExcept) {··· for (var i = 0, l = allExcept.length; i < l; i++) { this._allowedConstructors[allExcept[i]] = true; } } |
| ✓ Negative was executed (else) | }··· }, |
| Function (anonymous_820) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireCapitalizedConstructorsNew'; }, |
| Function (anonymous_821) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var allowedConstructors = this._allowedConstructors; file.iterateNodesByType('CallExpression', function(node) { if (node.callee.type === 'Identifier' && !allowedConstructors[node.callee.name] && node.callee.name[0].toLowerCase() !== node.callee.name[0] ) { errors.add( 'Constructor functions should use the "new" keyword', node.callee.loc.start.line, node.callee.loc.start.column ); } }); } |
| Function (anonymous_822) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('CallExpression', function(node) {··· if (node.callee.type === 'Identifier' && !allowedConstructors[node.callee.name] && node.callee.name[0].toLowerCase() !== node.callee.name[0] ) { errors.add( 'Constructor functions should use the "new" keyword', node.callee.loc.start.line, node.callee.loc.start.column ); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | ) {··· errors.add( 'Constructor functions should use the "new" keyword', node.callee.loc.start.line, node.callee.loc.start.column ); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | node.callee.name[0].toLowerCase() !== node.callee.name[0] |
| ✓ Was returned | if (node.callee.type === 'Identifier' &&··· !allowedConstructors[node.callee.name] && |
| Branch LogicalExpression | |
| ✓ Was returned | !allowedConstructors[node.callee.name] && |
| ✓ Was returned | if (node.callee.type === 'Identifier' && |
| Function (anonymous_823) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_824) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true || Array.isArray(options.allExcept), this.getOptionName() + ' option requires a true value or an object of exceptions' ); this._allowedConstructors = {}; var allExcept = options.allExcept; if (allExcept) { for (var i = 0, l = allExcept.length; i < l; i++) { this._allowedConstructors[allExcept[i]] = true; } } }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options === true || Array.isArray(options.allExcept), |
| ✓ Was returned | options === true || Array.isArray(options.allExcept), |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (allExcept) {··· for (var i = 0, l = allExcept.length; i < l; i++) { this._allowedConstructors[allExcept[i]] = true; } } |
| ✓ Negative was executed (else) | }··· }, |
| Function (anonymous_825) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireCapitalizedConstructors'; }, |
| Function (anonymous_826) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var allowedConstructors = this._allowedConstructors; file.iterateNodesByType('NewExpression', function(node) { if (node.callee.type === 'Identifier' && !allowedConstructors[node.callee.name] && node.callee.name[0].toUpperCase() !== node.callee.name[0] ) { errors.add( 'Constructor functions should be capitalized', node.callee.loc.start.line, node.callee.loc.start.column ); } }); } |
| Function (anonymous_827) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('NewExpression', function(node) {··· if (node.callee.type === 'Identifier' && !allowedConstructors[node.callee.name] && node.callee.name[0].toUpperCase() !== node.callee.name[0] ) { errors.add( 'Constructor functions should be capitalized', node.callee.loc.start.line, node.callee.loc.start.column ); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | ) {··· errors.add( 'Constructor functions should be capitalized', node.callee.loc.start.line, node.callee.loc.start.column ); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | node.callee.name[0].toUpperCase() !== node.callee.name[0] |
| ✓ Was returned | if (node.callee.type === 'Identifier' &&··· !allowedConstructors[node.callee.name] && |
| Branch LogicalExpression | |
| ✓ Was returned | !allowedConstructors[node.callee.name] && |
| ✓ Was returned | if (node.callee.type === 'Identifier' && |
| Function (anonymous_828) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_829) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_830) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireCommaBeforeLineBreak'; }, |
| Function (anonymous_831) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { var prevToken = file.getPrevToken(token); if (prevToken.value === ',') { return; } errors.assert.sameLine({ token: prevToken, nextToken: token, message: 'Commas should not be placed on new line' }); }); } |
| Function (anonymous_832) | |
|---|---|
| ✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) {··· var prevToken = file.getPrevToken(token); if (prevToken.value === ',') { return; } errors.assert.sameLine({ token: prevToken, nextToken: token, message: 'Commas should not be placed on new line' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (prevToken.value === ',') {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.sameLine({ |
| Function (anonymous_833) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_834) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( Array.isArray(options) || options === true || typeof options === 'object', this.getOptionName() + ' option requires array, true value, or object' ); var keywordMap = { 'return': 'ReturnStatement', 'break': 'BreakStatement', 'continue': 'ContinueStatement' }; if (options === true) { options = defaultKeywords; } if (!Array.isArray(options)) { assert( Array.isArray(options.allExcept), this.getOptionName() + '.allExcept ' + 'property requires an array value' ); assert( Array.isArray(options.keywords) || options.keywords === true, this.getOptionName() + '.keywords ' + 'property requires an array value or a value of true' ); if (options.keywords === true) { options.keywords = defaultKeywords; } this._exceptions = options.allExcept.map(function(statementType) { return keywordMap[statementType]; }); options = options.keywords; } this._typeIndex = {}; for (var i = 0, l = options.length; i < l; i++) { this._typeIndex[options[i]] = true; } }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | Array.isArray(options) || options === true || typeof options === 'object', |
| ✓ Was returned | Array.isArray(options) || options === true || typeof options === 'object', |
| Branch LogicalExpression | |
| ✓ Was returned | Array.isArray(options) || options === true || typeof options === 'object', |
| ✓ Was returned | Array.isArray(options) || options === true || typeof options === 'object', |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options === true) {··· options = defaultKeywords; } |
| ✓ Negative was executed (else) | }··· if (!Array.isArray(options)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!Array.isArray(options)) {··· assert( Array.isArray(options.allExcept), this.getOptionName() + '.allExcept ' + 'property requires an array value' ); assert( Array.isArray(options.keywords) || options.keywords === true, this.getOptionName() + '.keywords ' + 'property requires an array value or a value of true' ); if (options.keywords === true) { options.keywords = defaultKeywords; } this._exceptions = options.allExcept.map(function(statementType) { return keywordMap[statementType]; }); options = options.keywords; } |
| ✓ Negative was executed (else) | }··· this._typeIndex = {}; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | Array.isArray(options.keywords) || options.keywords === true, |
| ✓ Was returned | Array.isArray(options.keywords) || options.keywords === true, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options.keywords === true) {··· options.keywords = defaultKeywords; } |
| ✓ Negative was executed (else) | }··· this._exceptions = options.allExcept.map(function(statementType) { |
| Function (anonymous_835) | |
|---|---|
| ✓ Was called | this._exceptions = options.allExcept.map(function(statementType) {··· return keywordMap[statementType]; }); |
| Function (anonymous_836) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireCurlyBraces'; }, |
| Function (anonymous_837) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var typeIndex = this._typeIndex; var exceptions = this._exceptions; function isNotABlockStatement(node) { return node && node.type !== 'BlockStatement'; } function addError(typeString, entity) { errors.add( typeString + ' statement without curly braces', entity.loc.start.line, entity.loc.start.column ); } function checkBody(type, typeString) { file.iterateNodesByType(type, function(node) { if (isNotABlockStatement(node.body)) { addError(typeString, node); } }); } if (typeIndex.if || typeIndex.else) { file.iterateNodesByType('IfStatement', function(node) { if (typeIndex.if && isNotABlockStatement(node.consequent) && // check exceptions for if and else !(exceptions && exceptions.indexOf(node.consequent.type) !== -1)) { addError('If', node); } if (typeIndex.else && isNotABlockStatement(node.alternate) && node.alternate.type !== 'IfStatement' && // check exceptions for if and else !(exceptions && exceptions.indexOf(node.consequent.type) !== -1)) { addError('Else', file.getPrevToken(file.getFirstNodeToken(node.alternate))); } }); } if (typeIndex.case || typeIndex.default) { file.iterateNodesByType('SwitchCase', function(node) { // empty case statement if (node.consequent.length === 0) { return; } if (node.consequent.length === 1 && node.consequent[0].type === 'BlockStatement') { return; } if (node.test === null && typeIndex.default) { addError('Default', node); } if (node.test !== null && typeIndex.case) { addError('Case', node); } }); } if (typeIndex.while) { checkBody('WhileStatement', 'While'); } if (typeIndex.for) { checkBody('ForStatement', 'For'); checkBody('ForInStatement', 'For in'); checkBody('ForOfStatement', 'For of'); } if (typeIndex.do) { checkBody('DoWhileStatement', 'Do while'); } if (typeIndex.with) { checkBody('WithStatement', 'With'); } } |
| Function isNotABlockStatement | |
|---|---|
| ✓ Was called | function isNotABlockStatement(node) {··· return node && node.type !== 'BlockStatement'; } |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | return node && node.type !== 'BlockStatement'; |
| ✓ Was returned | return node && node.type !== 'BlockStatement'; |
| Function addError | |
|---|---|
| ✓ Was called | function addError(typeString, entity) {··· errors.add( typeString + ' statement without curly braces', entity.loc.start.line, entity.loc.start.column ); } |
| Function checkBody | |
|---|---|
| ✓ Was called | function checkBody(type, typeString) {··· file.iterateNodesByType(type, function(node) { if (isNotABlockStatement(node.body)) { addError(typeString, node); } }); } |
| Function (anonymous_841) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(type, function(node) {··· if (isNotABlockStatement(node.body)) { addError(typeString, node); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isNotABlockStatement(node.body)) {··· addError(typeString, node); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeIndex.if || typeIndex.else) {··· file.iterateNodesByType('IfStatement', function(node) { if (typeIndex.if && isNotABlockStatement(node.consequent) && // check exceptions for if and else !(exceptions && exceptions.indexOf(node.consequent.type) !== -1)) { addError('If', node); } if (typeIndex.else && isNotABlockStatement(node.alternate) && node.alternate.type !== 'IfStatement' && // check exceptions for if and else !(exceptions && exceptions.indexOf(node.consequent.type) !== -1)) { addError('Else', file.getPrevToken(file.getFirstNodeToken(node.alternate))); } }); } |
| ✓ Negative was executed (else) | }··· if (typeIndex.case || typeIndex.default) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (typeIndex.if || typeIndex.else) { |
| ✓ Was returned | if (typeIndex.if || typeIndex.else) { |
| Function (anonymous_842) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('IfStatement', function(node) {··· if (typeIndex.if && isNotABlockStatement(node.consequent) && // check exceptions for if and else !(exceptions && exceptions.indexOf(node.consequent.type) !== -1)) { addError('If', node); } if (typeIndex.else && isNotABlockStatement(node.alternate) && node.alternate.type !== 'IfStatement' && // check exceptions for if and else !(exceptions && exceptions.indexOf(node.consequent.type) !== -1)) { addError('Else', file.getPrevToken(file.getFirstNodeToken(node.alternate))); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | !(exceptions && exceptions.indexOf(node.consequent.type) !== -1)) {··· addError('If', node); } |
| ✓ Negative was executed (else) | }··· if (typeIndex.else && isNotABlockStatement(node.alternate) && |
| Branch LogicalExpression | |
| ✓ Was returned | !(exceptions && exceptions.indexOf(node.consequent.type) !== -1)) { |
| ✓ Was returned | if (typeIndex.if && isNotABlockStatement(node.consequent) && |
| Branch LogicalExpression | |
| ✓ Was returned | if (typeIndex.if && isNotABlockStatement(node.consequent) && |
| ✓ Was returned | if (typeIndex.if && isNotABlockStatement(node.consequent) && |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | !(exceptions && exceptions.indexOf(node.consequent.type) !== -1)) { |
| ✓ Was returned | !(exceptions && exceptions.indexOf(node.consequent.type) !== -1)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | !(exceptions && exceptions.indexOf(node.consequent.type) !== -1)) {··· addError('Else', file.getPrevToken(file.getFirstNodeToken(node.alternate))); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | !(exceptions && exceptions.indexOf(node.consequent.type) !== -1)) { |
| ✓ Was returned | if (typeIndex.else && isNotABlockStatement(node.alternate) &&··· node.alternate.type !== 'IfStatement' && |
| Branch LogicalExpression | |
| ✓ Was returned | node.alternate.type !== 'IfStatement' && |
| ✓ Was returned | if (typeIndex.else && isNotABlockStatement(node.alternate) && |
| Branch LogicalExpression | |
| ✓ Was returned | if (typeIndex.else && isNotABlockStatement(node.alternate) && |
| ✓ Was returned | if (typeIndex.else && isNotABlockStatement(node.alternate) && |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | !(exceptions && exceptions.indexOf(node.consequent.type) !== -1)) { |
| ✓ Was returned | !(exceptions && exceptions.indexOf(node.consequent.type) !== -1)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeIndex.case || typeIndex.default) {··· file.iterateNodesByType('SwitchCase', function(node) { // empty case statement if (node.consequent.length === 0) { return; } if (node.consequent.length === 1 && node.consequent[0].type === 'BlockStatement') { return; } if (node.test === null && typeIndex.default) { addError('Default', node); } if (node.test !== null && typeIndex.case) { addError('Case', node); } }); } |
| ✓ Negative was executed (else) | }··· if (typeIndex.while) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (typeIndex.case || typeIndex.default) { |
| ✓ Was returned | if (typeIndex.case || typeIndex.default) { |
| Function (anonymous_843) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('SwitchCase', function(node) {··· // empty case statement if (node.consequent.length === 0) { return; } if (node.consequent.length === 1 && node.consequent[0].type === 'BlockStatement') { return; } if (node.test === null && typeIndex.default) { addError('Default', node); } if (node.test !== null && typeIndex.case) { addError('Case', node); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.consequent.length === 0) {··· return; } |
| ✓ Negative was executed (else) | }··· if (node.consequent.length === 1 && node.consequent[0].type === 'BlockStatement') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.consequent.length === 1 && node.consequent[0].type === 'BlockStatement') {··· return; } |
| ✓ Negative was executed (else) | }··· if (node.test === null && typeIndex.default) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (node.consequent.length === 1 && node.consequent[0].type === 'BlockStatement') { |
| ✓ Was returned | if (node.consequent.length === 1 && node.consequent[0].type === 'BlockStatement') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.test === null && typeIndex.default) {··· addError('Default', node); } |
| ✓ Negative was executed (else) | }··· if (node.test !== null && typeIndex.case) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (node.test === null && typeIndex.default) { |
| ✓ Was returned | if (node.test === null && typeIndex.default) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.test !== null && typeIndex.case) {··· addError('Case', node); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | if (node.test !== null && typeIndex.case) { |
| ✓ Was returned | if (node.test !== null && typeIndex.case) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeIndex.while) {··· checkBody('WhileStatement', 'While'); } |
| ✓ Negative was executed (else) | }··· if (typeIndex.for) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeIndex.for) {··· checkBody('ForStatement', 'For'); checkBody('ForInStatement', 'For in'); checkBody('ForOfStatement', 'For of'); } |
| ✓ Negative was executed (else) | }··· if (typeIndex.do) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeIndex.do) {··· checkBody('DoWhileStatement', 'Do while'); } |
| ✓ Negative was executed (else) | }··· if (typeIndex.with) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeIndex.with) {··· checkBody('WithStatement', 'With'); } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_844) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_845) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true || options === 'ignoreProperties', this.getOptionName() + ' option requires true or "ignoreProperties" value, or should be removed' ); this._ignoreProperties = (options === 'ignoreProperties'); }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options === true || options === 'ignoreProperties', |
| ✓ Was returned | options === true || options === 'ignoreProperties', |
| Function (anonymous_846) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireDollarBeforejQueryAssignment'; }, |
| Function (anonymous_847) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var ignoreProperties = this._ignoreProperties; file.iterateNodesByType(['VariableDeclarator', 'AssignmentExpression', 'ObjectExpression'], function(token) { var type = token.type; var left; var varName; var right; function checkIfVarNameShouldStartWithDollar(varName, left, right) { if (/^_?\$/.test(varName)) { return; } if (!right || right.type !== 'CallExpression') { return; } var nextToken = file.getTokenByRangeStart(right.callee.range[0]); if (nextToken.value !== '$') { return; } nextToken = file.getNextToken(nextToken); if (nextToken.value !== '(') { return; } while (!(nextToken.type === 'Punctuator' && nextToken.value === ')')) { nextToken = file.getNextToken(nextToken); } nextToken = file.getNextToken(nextToken); if (!nextToken || !(nextToken.type === 'Punctuator' && nextToken.value === '.')) { errors.add( 'jQuery identifiers must start with a $', left.loc.start.line, left.loc.start.column ); } } if (type === 'VariableDeclarator') { if (token.id.type === 'ObjectPattern' || token.id.type === 'ArrayPattern') { return; } left = token.id; varName = left.name; right = token.init; checkIfVarNameShouldStartWithDollar(varName, left, right); } else if (ignoreProperties) { return; } else if (type === 'AssignmentExpression') { left = token.left; if (left.computed) { return; } varName = left.name || left.property.name; right = token.right; checkIfVarNameShouldStartWithDollar(varName, left, right); } else {// type === 'ObjectExpression' var props = token.properties; if (!props) { return; } props.forEach(function(prop) { left = prop.key; if (!left.name) { return; } varName = left.name; right = prop.value; checkIfVarNameShouldStartWithDollar(varName, left, right); }); } }); } |
| Function (anonymous_848) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['VariableDeclarator', 'AssignmentExpression', 'ObjectExpression'], function(token) {··· var type = token.type; var left; var varName; var right; function checkIfVarNameShouldStartWithDollar(varName, left, right) { if (/^_?\$/.test(varName)) { return; } if (!right || right.type !== 'CallExpression') { return; } var nextToken = file.getTokenByRangeStart(right.callee.range[0]); if (nextToken.value !== '$') { return; } nextToken = file.getNextToken(nextToken); if (nextToken.value !== '(') { return; } while (!(nextToken.type === 'Punctuator' && nextToken.value === ')')) { nextToken = file.getNextToken(nextToken); } nextToken = file.getNextToken(nextToken); if (!nextToken || !(nextToken.type === 'Punctuator' && nextToken.value === '.')) { errors.add( 'jQuery identifiers must start with a $', left.loc.start.line, left.loc.start.column ); } } if (type === 'VariableDeclarator') { if (token.id.type === 'ObjectPattern' || token.id.type === 'ArrayPattern') { return; } left = token.id; varName = left.name; right = token.init; checkIfVarNameShouldStartWithDollar(varName, left, right); } else if (ignoreProperties) { return; } else if (type === 'AssignmentExpression') { left = token.left; if (left.computed) { return; } varName = left.name || left.property.name; right = token.right; checkIfVarNameShouldStartWithDollar(varName, left, right); } else {// type === 'ObjectExpression' var props = token.properties; if (!props) { return; } props.forEach(function(prop) { left = prop.key; if (!left.name) { return; } varName = left.name; right = prop.value; checkIfVarNameShouldStartWithDollar(varName, left, right); }); } }); |
| Function checkIfVarNameShouldStartWithDollar | |
|---|---|
| ✓ Was called | function checkIfVarNameShouldStartWithDollar(varName, left, right) {··· if (/^_?\$/.test(varName)) { return; } if (!right || right.type !== 'CallExpression') { return; } var nextToken = file.getTokenByRangeStart(right.callee.range[0]); if (nextToken.value !== '$') { return; } nextToken = file.getNextToken(nextToken); if (nextToken.value !== '(') { return; } while (!(nextToken.type === 'Punctuator' && nextToken.value === ')')) { nextToken = file.getNextToken(nextToken); } nextToken = file.getNextToken(nextToken); if (!nextToken || !(nextToken.type === 'Punctuator' && nextToken.value === '.')) { errors.add( 'jQuery identifiers must start with a $', left.loc.start.line, left.loc.start.column ); } } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (/^_?\$/.test(varName)) {··· return; } |
| ✓ Negative was executed (else) | }··· if (!right || right.type !== 'CallExpression') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!right || right.type !== 'CallExpression') {··· return; } |
| ✓ Negative was executed (else) | }··· var nextToken = file.getTokenByRangeStart(right.callee.range[0]); |
| Branch LogicalExpression | |
| ✓ Was returned | if (!right || right.type !== 'CallExpression') { |
| ✓ Was returned | if (!right || right.type !== 'CallExpression') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (nextToken.value !== '$') {··· return; } |
| ✓ Negative was executed (else) | }··· nextToken = file.getNextToken(nextToken); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (nextToken.value !== '(') {··· return; } |
| ✓ Negative was executed (else) | }··· while (!(nextToken.type === 'Punctuator' && nextToken.value === ')')) { |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | while (!(nextToken.type === 'Punctuator' && nextToken.value === ')')) { |
| ✓ Was returned | while (!(nextToken.type === 'Punctuator' && nextToken.value === ')')) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!nextToken || !(nextToken.type === 'Punctuator' && nextToken.value === '.')) {··· errors.add( 'jQuery identifiers must start with a $', left.loc.start.line, left.loc.start.column ); } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | if (!nextToken || !(nextToken.type === 'Punctuator' && nextToken.value === '.')) { |
| ✗ Was not returned | if (!nextToken || !(nextToken.type === 'Punctuator' && nextToken.value === '.')) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (!nextToken || !(nextToken.type === 'Punctuator' && nextToken.value === '.')) { |
| ✓ Was returned | if (!nextToken || !(nextToken.type === 'Punctuator' && nextToken.value === '.')) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (type === 'VariableDeclarator') {··· if (token.id.type === 'ObjectPattern' || token.id.type === 'ArrayPattern') { return; } left = token.id; varName = left.name; right = token.init; checkIfVarNameShouldStartWithDollar(varName, left, right); } else if (ignoreProperties) { |
| ✓ Negative was executed (else) | } else if (ignoreProperties) {··· return; } else if (type === 'AssignmentExpression') { left = token.left; if (left.computed) { return; } varName = left.name || left.property.name; right = token.right; checkIfVarNameShouldStartWithDollar(varName, left, right); } else {// type === 'ObjectExpression' var props = token.properties; if (!props) { return; } props.forEach(function(prop) { left = prop.key; if (!left.name) { return; } varName = left.name; right = prop.value; checkIfVarNameShouldStartWithDollar(varName, left, right); }); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (token.id.type === 'ObjectPattern' || token.id.type === 'ArrayPattern') {··· return; } |
| ✓ Negative was executed (else) | }··· left = token.id; |
| Branch LogicalExpression | |
| ✓ Was returned | if (token.id.type === 'ObjectPattern' || token.id.type === 'ArrayPattern') { |
| ✓ Was returned | if (token.id.type === 'ObjectPattern' || token.id.type === 'ArrayPattern') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (ignoreProperties) {··· return; } else if (type === 'AssignmentExpression') { |
| ✓ Negative was executed (else) | } else if (type === 'AssignmentExpression') {··· left = token.left; if (left.computed) { return; } varName = left.name || left.property.name; right = token.right; checkIfVarNameShouldStartWithDollar(varName, left, right); } else {// type === 'ObjectExpression' var props = token.properties; if (!props) { return; } props.forEach(function(prop) { left = prop.key; if (!left.name) { return; } varName = left.name; right = prop.value; checkIfVarNameShouldStartWithDollar(varName, left, right); }); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (type === 'AssignmentExpression') {··· left = token.left; if (left.computed) { return; } varName = left.name || left.property.name; right = token.right; checkIfVarNameShouldStartWithDollar(varName, left, right); } else {// type === 'ObjectExpression' |
| ✓ Negative was executed (else) | } else {// type === 'ObjectExpression'··· var props = token.properties; if (!props) { return; } props.forEach(function(prop) { left = prop.key; if (!left.name) { return; } varName = left.name; right = prop.value; checkIfVarNameShouldStartWithDollar(varName, left, right); }); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (left.computed) {··· return; } |
| ✓ Negative was executed (else) | }··· varName = left.name || left.property.name; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | varName = left.name || left.property.name; |
| ✓ Was returned | varName = left.name || left.property.name; |
| Branch IfStatement | |
|---|---|
| ✗ Positive was not executed (if) | if (!props) {··· return; } |
| ✓ Negative was executed (else) | }··· props.forEach(function(prop) { |
| Function (anonymous_850) | |
|---|---|
| ✓ Was called | props.forEach(function(prop) {··· left = prop.key; if (!left.name) { return; } varName = left.name; right = prop.value; checkIfVarNameShouldStartWithDollar(varName, left, right); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!left.name) {··· return; } |
| ✓ Negative was executed (else) | }··· varName = left.name; |
| Function (anonymous_851) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_852) | |
|---|---|
| ✓ Was called | configure: function(options) {··· if (typeof options !== 'object') { assert( options === true || options === 'except_snake_case', this.getOptionName() + ' option requires either a true value or an object' ); var _options = {}; if (options === 'except_snake_case') { _options.allExcept = ['snake_case']; } return this.configure(_options); } assert( !options.allExcept || Array.isArray(options.allExcept), 'allExcept value of ' + this.getOptionName() + ' option requires an array with exceptions' ); if (Array.isArray(options.allExcept)) { this._exceptSnakeCase = options.allExcept.indexOf('snake_case') > -1; this._exceptKeywords = options.allExcept.indexOf('keywords') > -1; } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof options !== 'object') {··· assert( options === true || options === 'except_snake_case', this.getOptionName() + ' option requires either a true value or an object' ); var _options = {}; if (options === 'except_snake_case') { _options.allExcept = ['snake_case']; } return this.configure(_options); } |
| ✓ Negative was executed (else) | }··· assert( |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options === true || options === 'except_snake_case', |
| ✓ Was returned | options === true || options === 'except_snake_case', |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options === 'except_snake_case') {··· _options.allExcept = ['snake_case']; } |
| ✓ Negative was executed (else) | }··· return this.configure(_options); |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | !options.allExcept || Array.isArray(options.allExcept), |
| ✓ Was returned | !options.allExcept || Array.isArray(options.allExcept), |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (Array.isArray(options.allExcept)) {··· this._exceptSnakeCase = options.allExcept.indexOf('snake_case') > -1; this._exceptKeywords = options.allExcept.indexOf('keywords') > -1; } |
| ✓ Negative was executed (else) | }··· }, |
| Function (anonymous_853) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireDotNotation'; }, |
| Function (anonymous_854) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var exceptSnakeCase = this._exceptSnakeCase; var exceptKeywords = this._exceptKeywords; var dialect = file.getDialect(); file.iterateNodesByType('MemberExpression', function(node) { if (!node.computed || node.property.type !== 'Literal') { return; } var value = node.property.value; if (// allow numbers, nulls, and anything else typeof value !== 'string' || // allow invalid identifiers !utils.isValidIdentifierName(value, file.getDialect()) || // allow quoted snake cased identifiers if allExcept: ['snake_case'] (exceptSnakeCase && utils.isSnakeCased(utils.trimUnderscores(value))) || // allow quoted reserved words if allExcept: ['keywords'] ((dialect === 'es3' || exceptKeywords) && reservedWords.check(value, dialect, true)) ) { return; } errors.add( 'Use dot notation instead of brackets for member expressions', node.property.loc.start ); }); } |
| Function (anonymous_855) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('MemberExpression', function(node) {··· if (!node.computed || node.property.type !== 'Literal') { return; } var value = node.property.value; if (// allow numbers, nulls, and anything else typeof value !== 'string' || // allow invalid identifiers !utils.isValidIdentifierName(value, file.getDialect()) || // allow quoted snake cased identifiers if allExcept: ['snake_case'] (exceptSnakeCase && utils.isSnakeCased(utils.trimUnderscores(value))) || // allow quoted reserved words if allExcept: ['keywords'] ((dialect === 'es3' || exceptKeywords) && reservedWords.check(value, dialect, true)) ) { return; } errors.add( 'Use dot notation instead of brackets for member expressions', node.property.loc.start ); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!node.computed || node.property.type !== 'Literal') {··· return; } |
| ✓ Negative was executed (else) | }··· var value = node.property.value; |
| Branch LogicalExpression | |
| ✓ Was returned | if (!node.computed || node.property.type !== 'Literal') { |
| ✓ Was returned | if (!node.computed || node.property.type !== 'Literal') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | ) {··· return; } |
| ✓ Negative was executed (else) | }··· errors.add( |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | ((dialect === 'es3' || exceptKeywords) && reservedWords.check(value, dialect, true)) |
| ✓ Was returned | typeof value !== 'string' ||··· // allow invalid identifiers !utils.isValidIdentifierName(value, file.getDialect()) || // allow quoted snake cased identifiers if allExcept: ['snake_case'] (exceptSnakeCase && utils.isSnakeCased(utils.trimUnderscores(value))) || |
| Branch LogicalExpression | |
| ✓ Was returned | (exceptSnakeCase && utils.isSnakeCased(utils.trimUnderscores(value))) || |
| ✓ Was returned | typeof value !== 'string' ||··· // allow invalid identifiers !utils.isValidIdentifierName(value, file.getDialect()) || |
| Branch LogicalExpression | |
| ✓ Was returned | !utils.isValidIdentifierName(value, file.getDialect()) || |
| ✓ Was returned | typeof value !== 'string' || |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | (exceptSnakeCase && utils.isSnakeCased(utils.trimUnderscores(value))) || |
| ✓ Was returned | (exceptSnakeCase && utils.isSnakeCased(utils.trimUnderscores(value))) || |
| Branch LogicalExpression | |
|---|---|
| ✗ Was not returned | ((dialect === 'es3' || exceptKeywords) && reservedWords.check(value, dialect, true)) |
| ✓ Was returned | ((dialect === 'es3' || exceptKeywords) && reservedWords.check(value, dialect, true)) |
| Branch LogicalExpression | |
| ✓ Was returned | ((dialect === 'es3' || exceptKeywords) && reservedWords.check(value, dialect, true)) |
| ✗ Was not returned | ((dialect === 'es3' || exceptKeywords) && reservedWords.check(value, dialect, true)) |
| Function (anonymous_856) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_857) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option allow only the `true` value' ); }, |
| Function (anonymous_858) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireEarlyReturn'; }, |
| Function (anonymous_859) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· function addError(entity) { errors.add( 'Use of else after return', entity.loc.start.line, entity.loc.start.column ); } // Check if the IfStatement node contain a ReturnStatement. // If the node has a block, check all the statements in backward order to see if there is one. // This is to ensure that code like this will still return true: // // if (true) { // return; // eval(); // } function hasNodeReturn(node) { if (node.type === 'BlockStatement') { for (var i = node.body.length - 1; i >= 0; i--) { if (node.body[i].type === 'ReturnStatement') { return true; } } return false; } return node.type === 'ReturnStatement'; } file.iterateNodesByType('IfStatement', function(node) { if (!node.alternate) { return; } // Check if all the parents have a return statement, if not continue to the following IfStatement node. // // Example: // // if (foo) { // return; // } else if (bar) { <-- error // bar(); // } else if (baz) { <-- safe // return baz(); // } else { <-- safe // bas(); // } for (var nodeIf = node; nodeIf && nodeIf.type === 'IfStatement'; nodeIf = nodeIf.parentNode) { if (nodeIf.alternate && !hasNodeReturn(nodeIf.consequent)) { return; } } return addError(file.getPrevToken(file.getFirstNodeToken(node.alternate))); }); } |
| Function addError | |
|---|---|
| ✓ Was called | function addError(entity) {··· errors.add( 'Use of else after return', entity.loc.start.line, entity.loc.start.column ); } |
| Function hasNodeReturn | |
|---|---|
| ✓ Was called | function hasNodeReturn(node) {··· if (node.type === 'BlockStatement') { for (var i = node.body.length - 1; i >= 0; i--) { if (node.body[i].type === 'ReturnStatement') { return true; } } return false; } return node.type === 'ReturnStatement'; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.type === 'BlockStatement') {··· for (var i = node.body.length - 1; i >= 0; i--) { if (node.body[i].type === 'ReturnStatement') { return true; } } return false; } |
| ✓ Negative was executed (else) | }··· return node.type === 'ReturnStatement'; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.body[i].type === 'ReturnStatement') {··· return true; } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_862) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('IfStatement', function(node) {··· if (!node.alternate) { return; } // Check if all the parents have a return statement, if not continue to the following IfStatement node. // // Example: // // if (foo) { // return; // } else if (bar) { <-- error // bar(); // } else if (baz) { <-- safe // return baz(); // } else { <-- safe // bas(); // } for (var nodeIf = node; nodeIf && nodeIf.type === 'IfStatement'; nodeIf = nodeIf.parentNode) { if (nodeIf.alternate && !hasNodeReturn(nodeIf.consequent)) { return; } } return addError(file.getPrevToken(file.getFirstNodeToken(node.alternate))); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!node.alternate) {··· return; } |
| ✓ Negative was executed (else) | }··· // Check if all the parents have a return statement, if not continue to the following IfStatement node. |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | for (var nodeIf = node; nodeIf && nodeIf.type === 'IfStatement'; nodeIf = nodeIf.parentNode) { |
| ✗ Was not returned | for (var nodeIf = node; nodeIf && nodeIf.type === 'IfStatement'; nodeIf = nodeIf.parentNode) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (nodeIf.alternate && !hasNodeReturn(nodeIf.consequent)) {··· return; } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | if (nodeIf.alternate && !hasNodeReturn(nodeIf.consequent)) { |
| ✓ Was returned | if (nodeIf.alternate && !hasNodeReturn(nodeIf.consequent)) { |
| Function (anonymous_863) | |
|---|---|
| ✓ Was called | module.exports = function() { }; |
| Function (anonymous_864) | |
|---|---|
| ✓ Was called | configure: function(option) {··· assert(option === true, this.getOptionName() + ' requires a true value'); }, |
| Function (anonymous_865) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireEnhancedObjectLiterals'; }, |
| Function (anonymous_866) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('Property', function(node) { // node.key.name is used when the property key is an unquoted identifier // node.key.value is used when the property key is a quoted string var propertyName = node.key.name || node.key.value; var valueName = node.value.name; var shorthand = node.shorthand; var computed = node.computed; // check for non-shorthand properties if (propertyName && propertyName === valueName && !(shorthand || computed)) { errors.add( 'Property assignment should use enhanced object literal function.\n' + ' `{ propName: propName }` is not allowed.', node.loc.start ); } // check for non-method function properties var valueType = node.value.type; var valueIsMethod = node.method; if (valueType === 'FunctionExpression' && !valueIsMethod) { errors.add( 'Property assignment should use enhanced object literal function.\n' + ' `{ funcName: function() {} }` is not allowed.', node.loc.start ); } }); } |
| Function (anonymous_867) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('Property', function(node) {··· // node.key.name is used when the property key is an unquoted identifier // node.key.value is used when the property key is a quoted string var propertyName = node.key.name || node.key.value; var valueName = node.value.name; var shorthand = node.shorthand; var computed = node.computed; // check for non-shorthand properties if (propertyName && propertyName === valueName && !(shorthand || computed)) { errors.add( 'Property assignment should use enhanced object literal function.\n' + ' `{ propName: propName }` is not allowed.', node.loc.start ); } // check for non-method function properties var valueType = node.value.type; var valueIsMethod = node.method; if (valueType === 'FunctionExpression' && !valueIsMethod) { errors.add( 'Property assignment should use enhanced object literal function.\n' + ' `{ funcName: function() {} }` is not allowed.', node.loc.start ); } }); |
| Branch LogicalExpression | |
|---|---|
| ✗ Was not returned | var propertyName = node.key.name || node.key.value; |
| ✓ Was returned | var propertyName = node.key.name || node.key.value; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (propertyName && propertyName === valueName && !(shorthand || computed)) {··· errors.add( 'Property assignment should use enhanced object literal function.\n' + ' `{ propName: propName }` is not allowed.', node.loc.start ); } |
| ✓ Negative was executed (else) | }··· // check for non-method function properties |
| Branch LogicalExpression | |
| ✓ Was returned | if (propertyName && propertyName === valueName && !(shorthand || computed)) { |
| ✓ Was returned | if (propertyName && propertyName === valueName && !(shorthand || computed)) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (propertyName && propertyName === valueName && !(shorthand || computed)) { |
| ✗ Was not returned | if (propertyName && propertyName === valueName && !(shorthand || computed)) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (propertyName && propertyName === valueName && !(shorthand || computed)) { |
| ✓ Was returned | if (propertyName && propertyName === valueName && !(shorthand || computed)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (valueType === 'FunctionExpression' && !valueIsMethod) {··· errors.add( 'Property assignment should use enhanced object literal function.\n' + ' `{ funcName: function() {} }` is not allowed.', node.loc.start ); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | if (valueType === 'FunctionExpression' && !valueIsMethod) { |
| ✓ Was returned | if (valueType === 'FunctionExpression' && !valueIsMethod) { |
| Function (anonymous_868) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_869) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_870) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireFunctionDeclarations'; }, |
| Function (anonymous_871) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType( 'VariableDeclarator', function(node) { if (node.init && node.init.type === 'FunctionExpression') { errors.add('Use a function declaration instead', node.loc.start); } } ); file.iterateNodesByType( 'AssignmentExpression', function(node) { if (node.left.type !== 'MemberExpression' && node.right.type === 'FunctionExpression') { errors.add('Use a function declaration instead', node.loc.start); } } ); } |
| Function (anonymous_872) | |
|---|---|
| ✓ Was called | function(node) {··· if (node.init && node.init.type === 'FunctionExpression') { errors.add('Use a function declaration instead', node.loc.start); } } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.init && node.init.type === 'FunctionExpression') {··· errors.add('Use a function declaration instead', node.loc.start); } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | if (node.init && node.init.type === 'FunctionExpression') { |
| ✓ Was returned | if (node.init && node.init.type === 'FunctionExpression') { |
| Function (anonymous_873) | |
|---|---|
| ✓ Was called | function(node) {··· if (node.left.type !== 'MemberExpression' && node.right.type === 'FunctionExpression') { errors.add('Use a function declaration instead', node.loc.start); } } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | node.right.type === 'FunctionExpression') {··· errors.add('Use a function declaration instead', node.loc.start); } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | node.right.type === 'FunctionExpression') { |
| ✓ Was returned | if (node.left.type !== 'MemberExpression' && |
| Function (anonymous_874) | |
|---|---|
| ✓ Was called | module.exports = function() {··· }; |
| Function (anonymous_875) | |
|---|---|
| ✓ Was called | configure: function(option) {··· assert( option === true, this.getOptionName() + ' option requires true value' ); }, |
| Function (anonymous_876) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireImportAlphabetized'; }, |
| Function (anonymous_877) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var previous; var current; var createSpecHash = function(specifier) { var imported = ''; var local = ''; if (specifier.imported && specifier.imported.name) { imported = specifier.imported.name; } if (specifier.local && specifier.local.name) { local = specifier.local.name; } return imported === local ? imported : imported + local; }; file.iterateNodesByType( 'ImportDeclaration', function(node) { current = ''; for (var i = 0; i < node.specifiers.length; i++) { current += createSpecHash(node.specifiers[i]); } if (node.source && node.source.value) { current += node.source.value; } if (previous && previous > current) { errors.add('imports must be alphabetized', node.loc.start.line, node.loc.start.column); } previous = current; } ); } |
| Function (anonymous_878) | |
|---|---|
| ✓ Was called | var createSpecHash = function(specifier) {··· var imported = ''; var local = ''; if (specifier.imported && specifier.imported.name) { imported = specifier.imported.name; } if (specifier.local && specifier.local.name) { local = specifier.local.name; } return imported === local ? imported : imported + local; }; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (specifier.imported && specifier.imported.name) {··· imported = specifier.imported.name; } |
| ✓ Negative was executed (else) | }··· if (specifier.local && specifier.local.name) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (specifier.imported && specifier.imported.name) { |
| ✓ Was returned | if (specifier.imported && specifier.imported.name) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (specifier.local && specifier.local.name) {··· local = specifier.local.name; } |
| ✗ Negative was not executed (else) | }··· return imported === local ? imported : imported + local; |
| Branch LogicalExpression | |
| ✓ Was returned | if (specifier.local && specifier.local.name) { |
| ✗ Was not returned | if (specifier.local && specifier.local.name) { |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | return imported === local ? imported : imported + local; |
| ✓ Negative was returned (: ...) | return imported === local ? imported : imported + local; |
| Function (anonymous_879) | |
|---|---|
| ✓ Was called | function(node) {··· current = ''; for (var i = 0; i < node.specifiers.length; i++) { current += createSpecHash(node.specifiers[i]); } if (node.source && node.source.value) { current += node.source.value; } if (previous && previous > current) { errors.add('imports must be alphabetized', node.loc.start.line, node.loc.start.column); } previous = current; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.source && node.source.value) {··· current += node.source.value; } |
| ✗ Negative was not executed (else) | }··· if (previous && previous > current) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (node.source && node.source.value) { |
| ✗ Was not returned | if (node.source && node.source.value) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (previous && previous > current) {··· errors.add('imports must be alphabetized', node.loc.start.line, node.loc.start.column); } |
| ✓ Negative was executed (else) | }··· previous = current; |
| Branch LogicalExpression | |
| ✓ Was returned | if (previous && previous > current) { |
| ✓ Was returned | if (previous && previous > current) { |
| Function (anonymous_880) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_881) | |
|---|---|
| ✓ Was called | configure: function(keywords) {··· assert(Array.isArray(keywords), this.getOptionName() + ' option requires array value'); this._keywords = keywords; }, |
| Function (anonymous_882) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireKeywordsOnNewLine'; }, |
| Function (anonymous_883) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) { errors.assert.differentLine({ token: file.getPrevToken(token), nextToken: token }); }); } |
| Function (anonymous_884) | |
|---|---|
| ✓ Was called | file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) {··· errors.assert.differentLine({ token: file.getPrevToken(token), nextToken: token }); }); |
| Function (anonymous_885) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_886) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_887) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireLineBreakAfterVariableAssignment'; }, |
| Function (anonymous_888) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var lastDeclaration; file.iterateNodesByType('VariableDeclaration', function(node) { if (node.parentNode.type === 'ForStatement' || node.parentNode.type === 'ForInStatement' || node.parentNode.type === 'ForOfStatement') { return; } for (var i = 0; i < node.declarations.length; i++) { var thisDeclaration = node.declarations[i]; if (thisDeclaration.parentNode.kind === 'var' || thisDeclaration.parentNode.kind === 'let' || thisDeclaration.parentNode.kind === 'const') { if (lastDeclaration && lastDeclaration.init) { errors.assert.differentLine({ token: lastDeclaration, nextToken: thisDeclaration, message: 'Variable assignments should be followed by new line' }); } lastDeclaration = thisDeclaration; } } }); } |
| Function (anonymous_889) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('VariableDeclaration', function(node) {··· if (node.parentNode.type === 'ForStatement' || node.parentNode.type === 'ForInStatement' || node.parentNode.type === 'ForOfStatement') { return; } for (var i = 0; i < node.declarations.length; i++) { var thisDeclaration = node.declarations[i]; if (thisDeclaration.parentNode.kind === 'var' || thisDeclaration.parentNode.kind === 'let' || thisDeclaration.parentNode.kind === 'const') { if (lastDeclaration && lastDeclaration.init) { errors.assert.differentLine({ token: lastDeclaration, nextToken: thisDeclaration, message: 'Variable assignments should be followed by new line' }); } lastDeclaration = thisDeclaration; } } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | node.parentNode.type === 'ForOfStatement') {··· return; } |
| ✓ Negative was executed (else) | }··· for (var i = 0; i < node.declarations.length; i++) { |
| Branch LogicalExpression | |
| ✓ Was returned | node.parentNode.type === 'ForOfStatement') { |
| ✓ Was returned | if (node.parentNode.type === 'ForStatement' ||··· node.parentNode.type === 'ForInStatement' || |
| Branch LogicalExpression | |
| ✓ Was returned | node.parentNode.type === 'ForInStatement' || |
| ✓ Was returned | if (node.parentNode.type === 'ForStatement' || |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | thisDeclaration.parentNode.kind === 'const') {··· if (lastDeclaration && lastDeclaration.init) { errors.assert.differentLine({ token: lastDeclaration, nextToken: thisDeclaration, message: 'Variable assignments should be followed by new line' }); } lastDeclaration = thisDeclaration; } |
| ✗ Negative was not executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | thisDeclaration.parentNode.kind === 'const') { |
| ✓ Was returned | if (thisDeclaration.parentNode.kind === 'var' ||··· thisDeclaration.parentNode.kind === 'let' || |
| Branch LogicalExpression | |
| ✓ Was returned | thisDeclaration.parentNode.kind === 'let' || |
| ✓ Was returned | if (thisDeclaration.parentNode.kind === 'var' || |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (lastDeclaration && lastDeclaration.init) {··· errors.assert.differentLine({ token: lastDeclaration, nextToken: thisDeclaration, message: 'Variable assignments should be followed by new line' }); } |
| ✓ Negative was executed (else) | }··· lastDeclaration = thisDeclaration; |
| Branch LogicalExpression | |
| ✓ Was returned | if (lastDeclaration && lastDeclaration.init) { |
| ✓ Was returned | if (lastDeclaration && lastDeclaration.init) { |
| Function (anonymous_890) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_891) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_892) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireLineFeedAtFileEnd'; }, |
| Function (anonymous_893) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var lastToken = file.getLastToken({includeComments: true}); var prevToken = file.getPrevToken(lastToken, {includeComments: true}); errors.assert.differentLine({ token: prevToken, nextToken: lastToken, message: 'Missing line feed at file end' }); } |
| Function (anonymous_894) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_895) | |
|---|---|
| ✓ Was called | configure: function(requireMatchingFunctionName) {··· if (typeof requireMatchingFunctionName === 'object') { assert(requireMatchingFunctionName.includeModuleExports === true, 'requireMatchingFunctionName option requires includeModuleExports property to be true for object'); this._includeModuleExports = requireMatchingFunctionName.includeModuleExports; } else { assert( requireMatchingFunctionName === true, 'requireMatchingFunctionName option requires true value or should be removed' ); } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof requireMatchingFunctionName === 'object') {··· assert(requireMatchingFunctionName.includeModuleExports === true, 'requireMatchingFunctionName option requires includeModuleExports property to be true for object'); this._includeModuleExports = requireMatchingFunctionName.includeModuleExports; } else { |
| ✓ Negative was executed (else) | } else {··· assert( requireMatchingFunctionName === true, 'requireMatchingFunctionName option requires true value or should be removed' ); } |
| Function (anonymous_896) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireMatchingFunctionName'; }, |
| Function (anonymous_897) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var _includeModuleExports = this._includeModuleExports; file.iterateNodesByType(['FunctionExpression'], function(node) { switch (node.parentNode.type) { // var foo = function bar() {} // object.foo = function bar() {} // object['foo'] = function bar() {} case 'AssignmentExpression': if (_includeModuleExports || !_isModuleExports(node.parentNode.left)) { checkForMember(node.parentNode, skip, errors); } break; // object = {foo: function bar() {}} case 'Property': checkForProperty(node.parentNode, skip, errors); break; } }); function skip(key, value) { // We don't care about anonymous functions as // those should be enforced by separate rule if (!value.id) { return true; } // Relax a bit when reserved word is detected if (reservedWords.check(key, file.getDialect(), true)) { return true; } } } |
| Function (anonymous_898) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['FunctionExpression'], function(node) {··· switch (node.parentNode.type) { // var foo = function bar() {} // object.foo = function bar() {} // object['foo'] = function bar() {} case 'AssignmentExpression': if (_includeModuleExports || !_isModuleExports(node.parentNode.left)) { checkForMember(node.parentNode, skip, errors); } break; // object = {foo: function bar() {}} case 'Property': checkForProperty(node.parentNode, skip, errors); break; } }); |
| Branch SwitchStatement | |
|---|---|
| ✓ Was evaluated | case 'AssignmentExpression':··· if (_includeModuleExports || !_isModuleExports(node.parentNode.left)) { checkForMember(node.parentNode, skip, errors); } break; |
| ✓ Was evaluated | case 'Property':··· checkForProperty(node.parentNode, skip, errors); break; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (_includeModuleExports || !_isModuleExports(node.parentNode.left)) {··· checkForMember(node.parentNode, skip, errors); } |
| ✓ Negative was executed (else) | }··· break; |
| Branch LogicalExpression | |
| ✓ Was returned | if (_includeModuleExports || !_isModuleExports(node.parentNode.left)) { |
| ✓ Was returned | if (_includeModuleExports || !_isModuleExports(node.parentNode.left)) { |
| Function skip | |
|---|---|
| ✓ Was called | function skip(key, value) {··· // We don't care about anonymous functions as // those should be enforced by separate rule if (!value.id) { return true; } // Relax a bit when reserved word is detected if (reservedWords.check(key, file.getDialect(), true)) { return true; } } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!value.id) {··· return true; } |
| ✓ Negative was executed (else) | }··· // Relax a bit when reserved word is detected |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (reservedWords.check(key, file.getDialect(), true)) {··· return true; } |
| ✓ Negative was executed (else) | }··· } |
| Function _isModuleExports | |
|---|---|
| ✓ Was called | function _isModuleExports(pattern) {··· if (pattern.type === 'MemberExpression') { // must be module.sth if (pattern.object.type === 'Identifier' && pattern.object.name === 'module') { if (pattern.property.type === 'Identifier' && pattern.property.name === 'exports') { // sth.exports return true; } else if (pattern.property.type === 'Literal' && pattern.property.value === 'exports') { // sth["exports"] return true; } } } return false; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (pattern.type === 'MemberExpression') {··· // must be module.sth if (pattern.object.type === 'Identifier' && pattern.object.name === 'module') { if (pattern.property.type === 'Identifier' && pattern.property.name === 'exports') { // sth.exports return true; } else if (pattern.property.type === 'Literal' && pattern.property.value === 'exports') { // sth["exports"] return true; } } } |
| ✓ Negative was executed (else) | }··· return false; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | pattern.object.name === 'module') {··· if (pattern.property.type === 'Identifier' && pattern.property.name === 'exports') { // sth.exports return true; } else if (pattern.property.type === 'Literal' && pattern.property.value === 'exports') { // sth["exports"] return true; } } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | pattern.object.name === 'module') { |
| ✓ Was returned | if (pattern.object.type === 'Identifier' && |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | pattern.property.name === 'exports') {··· // sth.exports return true; } else if (pattern.property.type === 'Literal' && |
| ✓ Negative was executed (else) | } else if (pattern.property.type === 'Literal' &&··· pattern.property.value === 'exports') { // sth["exports"] return true; } |
| Branch LogicalExpression | |
| ✓ Was returned | pattern.property.name === 'exports') { |
| ✓ Was returned | if (pattern.property.type === 'Identifier' && |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | pattern.property.value === 'exports') {··· // sth["exports"] return true; } |
| ✗ Negative was not executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | pattern.property.value === 'exports') { |
| ✗ Was not returned | } else if (pattern.property.type === 'Literal' && |
| Function _resolvePatternName | |
|---|---|
| ✓ Was called | function _resolvePatternName(pattern) {··· switch (pattern.type) { case 'Identifier': // prop = ...; return pattern.name; case 'Literal': // obj['prop'] = ...; return pattern.value; case 'MemberExpression': // obj.prop = ...; return _resolvePatternName(pattern.property); default: // Something unhandy like obj['x' + 2] = ...; return false; } } |
| Branch SwitchStatement | |
|---|---|
| ✓ Was evaluated | case 'Identifier':··· // prop = ...; return pattern.name; |
| ✓ Was evaluated | case 'Literal':··· // obj['prop'] = ...; return pattern.value; |
| ✓ Was evaluated | case 'MemberExpression':··· // obj.prop = ...; return _resolvePatternName(pattern.property); |
| ✓ Was evaluated | default:··· // Something unhandy like obj['x' + 2] = ...; return false; |
| Function checkForMember | |
|---|---|
| ✓ Was called | function checkForMember(assignment, skip, errors) {··· var _name = _resolvePatternName(assignment.left); if (_name === false || skip(_name, assignment.right)) { return; } if (_name !== assignment.right.id.name) { errors.add( 'Function name does not match member name', assignment.loc.start ); } } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (_name === false || skip(_name, assignment.right)) {··· return; } |
| ✓ Negative was executed (else) | }··· if (_name !== assignment.right.id.name) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (_name === false || skip(_name, assignment.right)) { |
| ✓ Was returned | if (_name === false || skip(_name, assignment.right)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (_name !== assignment.right.id.name) {··· errors.add( 'Function name does not match member name', assignment.loc.start ); } |
| ✓ Negative was executed (else) | }··· } |
| Function checkForProperty | |
|---|---|
| ✓ Was called | function checkForProperty(property, skip, errors) {··· var _name = _resolvePatternName(property.key); if (_name === false || skip(_name, property.value)) { return; } if (_name !== property.value.id.name) { errors.add( 'Function name does not match property name', property.loc.start ); } } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (_name === false || skip(_name, property.value)) {··· return; } |
| ✓ Negative was executed (else) | }··· if (_name !== property.value.id.name) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (_name === false || skip(_name, property.value)) { |
| ✓ Was returned | if (_name === false || skip(_name, property.value)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (_name !== property.value.id.name) {··· errors.add( 'Function name does not match property name', property.loc.start ); } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_904) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_905) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_906) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireMultiLineTernary'; }, |
| Function (anonymous_907) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('ConditionalExpression', function(node) { errors.assert.differentLine({ token: node.test, nextToken: node.consequent, message: 'Missing new line after test' }); errors.assert.differentLine({ token: node.consequent, nextToken: node.alternate, message: 'Missing new line after consequent' }); }); } |
| Function (anonymous_908) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('ConditionalExpression', function(node) {··· errors.assert.differentLine({ token: node.test, nextToken: node.consequent, message: 'Missing new line after test' }); errors.assert.differentLine({ token: node.consequent, nextToken: node.alternate, message: 'Missing new line after consequent' }); }); |
| Function consecutive | |
|---|---|
| ✓ Was called | function consecutive(file, errors) {··· file.iterateNodesByType('VariableDeclaration', function(node) { var pos = node.parentCollection.indexOf(node); if (pos < node.parentCollection.length - 1) { var sibling = node.parentCollection[pos + 1]; if (sibling.type === 'VariableDeclaration' && sibling.kind === node.kind) { errors.add( node.kind[0].toUpperCase() + node.kind.slice(1) + ' declarations should be joined', sibling.loc.start ); } } }); } |
| Function (anonymous_910) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('VariableDeclaration', function(node) {··· var pos = node.parentCollection.indexOf(node); if (pos < node.parentCollection.length - 1) { var sibling = node.parentCollection[pos + 1]; if (sibling.type === 'VariableDeclaration' && sibling.kind === node.kind) { errors.add( node.kind[0].toUpperCase() + node.kind.slice(1) + ' declarations should be joined', sibling.loc.start ); } } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (pos < node.parentCollection.length - 1) {··· var sibling = node.parentCollection[pos + 1]; if (sibling.type === 'VariableDeclaration' && sibling.kind === node.kind) { errors.add( node.kind[0].toUpperCase() + node.kind.slice(1) + ' declarations should be joined', sibling.loc.start ); } } |
| ✓ Negative was executed (else) | }··· }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (sibling.type === 'VariableDeclaration' && sibling.kind === node.kind) {··· errors.add( node.kind[0].toUpperCase() + node.kind.slice(1) + ' declarations should be joined', sibling.loc.start ); } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | if (sibling.type === 'VariableDeclaration' && sibling.kind === node.kind) { |
| ✓ Was returned | if (sibling.type === 'VariableDeclaration' && sibling.kind === node.kind) { |
| Function onevar | |
|---|---|
| ✓ Was called | function onevar(file, errors) {··· file.iterateNodesByType(['Program', 'FunctionDeclaration', 'FunctionExpression'], function(node) { var firstVar = true; var firstConst = true; var firstParent = true; file.iterate(function(node) { var type = node.type; var kind = node.kind; // Don't go in nested scopes if (!firstParent && ['FunctionDeclaration', 'FunctionExpression'].indexOf(type) > -1) { return false; } if (firstParent) { firstParent = false; } if (type === 'VariableDeclaration') { if (kind === 'var') { if (!firstVar) { errors.add( 'Var declarations should be joined', node.loc.start ); } else { firstVar = false; } } if (kind === 'const') { if (!firstConst) { errors.add( 'Const declarations should be joined', node.loc.start ); } else { firstConst = false; } } } }, node); }); } |
| Function (anonymous_912) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['Program', 'FunctionDeclaration', 'FunctionExpression'], function(node) {··· var firstVar = true; var firstConst = true; var firstParent = true; file.iterate(function(node) { var type = node.type; var kind = node.kind; // Don't go in nested scopes if (!firstParent && ['FunctionDeclaration', 'FunctionExpression'].indexOf(type) > -1) { return false; } if (firstParent) { firstParent = false; } if (type === 'VariableDeclaration') { if (kind === 'var') { if (!firstVar) { errors.add( 'Var declarations should be joined', node.loc.start ); } else { firstVar = false; } } if (kind === 'const') { if (!firstConst) { errors.add( 'Const declarations should be joined', node.loc.start ); } else { firstConst = false; } } } }, node); }); |
| Function (anonymous_913) | |
|---|---|
| ✓ Was called | file.iterate(function(node) {··· var type = node.type; var kind = node.kind; // Don't go in nested scopes if (!firstParent && ['FunctionDeclaration', 'FunctionExpression'].indexOf(type) > -1) { return false; } if (firstParent) { firstParent = false; } if (type === 'VariableDeclaration') { if (kind === 'var') { if (!firstVar) { errors.add( 'Var declarations should be joined', node.loc.start ); } else { firstVar = false; } } if (kind === 'const') { if (!firstConst) { errors.add( 'Const declarations should be joined', node.loc.start ); } else { firstConst = false; } } } }, node); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!firstParent && ['FunctionDeclaration', 'FunctionExpression'].indexOf(type) > -1) {··· return false; } |
| ✓ Negative was executed (else) | }··· if (firstParent) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (!firstParent && ['FunctionDeclaration', 'FunctionExpression'].indexOf(type) > -1) { |
| ✓ Was returned | if (!firstParent && ['FunctionDeclaration', 'FunctionExpression'].indexOf(type) > -1) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (firstParent) {··· firstParent = false; } |
| ✓ Negative was executed (else) | }··· if (type === 'VariableDeclaration') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (type === 'VariableDeclaration') {··· if (kind === 'var') { if (!firstVar) { errors.add( 'Var declarations should be joined', node.loc.start ); } else { firstVar = false; } } if (kind === 'const') { if (!firstConst) { errors.add( 'Const declarations should be joined', node.loc.start ); } else { firstConst = false; } } } |
| ✓ Negative was executed (else) | }··· }, node); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (kind === 'var') {··· if (!firstVar) { errors.add( 'Var declarations should be joined', node.loc.start ); } else { firstVar = false; } } |
| ✓ Negative was executed (else) | }··· if (kind === 'const') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!firstVar) {··· errors.add( 'Var declarations should be joined', node.loc.start ); } else { |
| ✓ Negative was executed (else) | } else {··· firstVar = false; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (kind === 'const') {··· if (!firstConst) { errors.add( 'Const declarations should be joined', node.loc.start ); } else { firstConst = false; } } |
| ✓ Negative was executed (else) | }··· } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!firstConst) {··· errors.add( 'Const declarations should be joined', node.loc.start ); } else { |
| ✓ Negative was executed (else) | } else {··· firstConst = false; } |
| Function hasRequireStatements | |
|---|---|
| ✓ Was called | function hasRequireStatements(node) {··· if (!Array.isArray(node.declarations)) { return false; } return node.declarations.some(function(declaration) { var init = declaration.init; return init && init.callee && init.callee.name === 'require'; }); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!Array.isArray(node.declarations)) {··· return false; } |
| ✓ Negative was executed (else) | }··· return node.declarations.some(function(declaration) { |
| Function (anonymous_915) | |
|---|---|
| ✓ Was called | return node.declarations.some(function(declaration) {··· var init = declaration.init; return init && init.callee && init.callee.name === 'require'; }); |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | init.callee.name === 'require'; |
| ✓ Was returned | return init &&··· init.callee && |
| Branch LogicalExpression | |
| ✓ Was returned | init.callee && |
| ✓ Was returned | return init && |
| Function exceptRequire | |
|---|---|
| ✓ Was called | function exceptRequire(file, errors) {··· file.iterateNodesByType('VariableDeclaration', function(node) { if (hasRequireStatements(node)) { return; } var pos = node.parentCollection.indexOf(node); if (pos < node.parentCollection.length - 1) { var sibling = node.parentCollection[pos + 1]; if (hasRequireStatements(sibling)) { return; } if (sibling.type === 'VariableDeclaration' && sibling.kind === node.kind) { errors.add( node.kind[0].toUpperCase() + node.kind.slice(1) + ' declarations should be joined', sibling.loc.start ); } } }); } |
| Function (anonymous_917) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('VariableDeclaration', function(node) {··· if (hasRequireStatements(node)) { return; } var pos = node.parentCollection.indexOf(node); if (pos < node.parentCollection.length - 1) { var sibling = node.parentCollection[pos + 1]; if (hasRequireStatements(sibling)) { return; } if (sibling.type === 'VariableDeclaration' && sibling.kind === node.kind) { errors.add( node.kind[0].toUpperCase() + node.kind.slice(1) + ' declarations should be joined', sibling.loc.start ); } } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (hasRequireStatements(node)) {··· return; } |
| ✓ Negative was executed (else) | }··· var pos = node.parentCollection.indexOf(node); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (pos < node.parentCollection.length - 1) {··· var sibling = node.parentCollection[pos + 1]; if (hasRequireStatements(sibling)) { return; } if (sibling.type === 'VariableDeclaration' && sibling.kind === node.kind) { errors.add( node.kind[0].toUpperCase() + node.kind.slice(1) + ' declarations should be joined', sibling.loc.start ); } } |
| ✓ Negative was executed (else) | }··· }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (hasRequireStatements(sibling)) {··· return; } |
| ✓ Negative was executed (else) | }··· if (sibling.type === 'VariableDeclaration' && sibling.kind === node.kind) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (sibling.type === 'VariableDeclaration' && sibling.kind === node.kind) {··· errors.add( node.kind[0].toUpperCase() + node.kind.slice(1) + ' declarations should be joined', sibling.loc.start ); } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | if (sibling.type === 'VariableDeclaration' && sibling.kind === node.kind) { |
| ✓ Was returned | if (sibling.type === 'VariableDeclaration' && sibling.kind === node.kind) { |
| Function (anonymous_918) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_919) | |
|---|---|
| ✓ Was called | configure: function(options) {··· var isExceptRequire = typeof options === 'object' && options.allExcept.length && options.allExcept.indexOf('require') !== -1; assert( options === true || options === 'onevar' || isExceptRequire, this.getOptionName() + ' option requires a true value, `onevar` or {allExcept: [\'require\']}' ); var checkers = { true: consecutive, onevar: onevar }; this._check = isExceptRequire ? exceptRequire : checkers[options]; }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options.allExcept.indexOf('require') !== -1; |
| ✓ Was returned | var isExceptRequire = typeof options === 'object' &&··· options.allExcept.length && |
| Branch LogicalExpression | |
| ✓ Was returned | options.allExcept.length && |
| ✓ Was returned | var isExceptRequire = typeof options === 'object' && |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | isExceptRequire, |
| ✓ Was returned | options === true ||··· options === 'onevar' || |
| Branch LogicalExpression | |
| ✓ Was returned | options === 'onevar' || |
| ✓ Was returned | options === true || |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | this._check = isExceptRequire ? exceptRequire : checkers[options]; |
| ✓ Negative was returned (: ...) | this._check = isExceptRequire ? exceptRequire : checkers[options]; |
| Function (anonymous_920) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireMultipleVarDecl'; }, |
| Function (anonymous_921) | |
|---|---|
| ✓ Was called | check: function() {··· return this._check.apply(this, arguments); } |
| Function getNodeName | |
|---|---|
| ✓ Was called | function getNodeName(node) {··· if (node.type === 'Identifier') { return node.name; } else { return node.value; } } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.type === 'Identifier') {··· return node.name; } else { |
| ✓ Negative was executed (else) | } else {··· return node.value; } |
| Function (anonymous_923) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_924) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true || typeof options === 'object', this.getOptionName() + ' option requires true value ' + 'or an object with String[] `allExcept` property' ); // verify first item in `allExcept` property in object (if it's an object) assert( typeof options !== 'object' || Array.isArray(options.allExcept) && typeof options.allExcept[0] === 'string', 'Property `allExcept` in ' + this.getOptionName() + ' should be an array of strings' ); if (options.allExcept) { this._allExceptItems = options.allExcept.map(function(item) { var parts = pathval.parse(item).map(function extractPart(part) { return part.i !== undefined ? part.i : part.p; }); return JSON.stringify(parts); }); } }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | typeof options === 'object', |
| ✓ Was returned | options === true || |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | Array.isArray(options.allExcept) &&··· typeof options.allExcept[0] === 'string', |
| ✓ Was returned | typeof options !== 'object' || |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | typeof options.allExcept[0] === 'string', |
| ✓ Was returned | Array.isArray(options.allExcept) && |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options.allExcept) {··· this._allExceptItems = options.allExcept.map(function(item) { var parts = pathval.parse(item).map(function extractPart(part) { return part.i !== undefined ? part.i : part.p; }); return JSON.stringify(parts); }); } |
| ✓ Negative was executed (else) | }··· }, |
| Function (anonymous_925) | |
|---|---|
| ✓ Was called | this._allExceptItems = options.allExcept.map(function(item) {··· var parts = pathval.parse(item).map(function extractPart(part) { return part.i !== undefined ? part.i : part.p; }); return JSON.stringify(parts); }); |
| Function extractPart | |
|---|---|
| ✓ Was called | var parts = pathval.parse(item).map(function extractPart(part) {··· return part.i !== undefined ? part.i : part.p; }); |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | return part.i !== undefined ? part.i : part.p; |
| ✓ Negative was returned (: ...) | return part.i !== undefined ? part.i : part.p; |
| Function (anonymous_927) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireNamedUnassignedFunctions'; }, |
| Function (anonymous_928) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var _this = this; file.iterateNodesByType('FunctionExpression', function(node) { var parentNode = node.parentNode; // If the function has been named via left hand assignment, skip it // e.g. `var hello = function() {`, `foo.bar = function() {` if (parentNode.type.match(/VariableDeclarator|Property|AssignmentExpression/)) { return; } // If the function has been named, skip it // e.g. `[].forEach(function hello() {` if (node.id !== null) { return; } // If we have exceptions and the function is being invoked, detect whether we excepted it if (_this._allExceptItems && parentNode.type === 'CallExpression') { // Determine the path that resolves to our call expression // We must cover both direct calls (e.g. `it(function() {`) and // member expressions (e.g. `foo.bar(function() {`) var memberNode = parentNode.callee; var canBeRepresented = true; var fullpathParts = []; while (memberNode) { if (memberNode.type.match(/Identifier|Literal/)) { fullpathParts.unshift(getNodeName(memberNode)); } else if (memberNode.type === 'MemberExpression') { fullpathParts.unshift(getNodeName(memberNode.property)); } else { canBeRepresented = false; break; } memberNode = memberNode.object; } // If the path is not-dynamic (i.e. can be represented by static parts), // then check it against our exceptions if (canBeRepresented) { var fullpath = JSON.stringify(fullpathParts); for (var i = 0, l = _this._allExceptItems.length; i < l; i++) { if (fullpath === _this._allExceptItems[i]) { return; } } } } // Complain that this function must be named errors.add('Inline functions need to be named', node.loc.start); }); } |
| Function (anonymous_929) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('FunctionExpression', function(node) {··· var parentNode = node.parentNode; // If the function has been named via left hand assignment, skip it // e.g. `var hello = function() {`, `foo.bar = function() {` if (parentNode.type.match(/VariableDeclarator|Property|AssignmentExpression/)) { return; } // If the function has been named, skip it // e.g. `[].forEach(function hello() {` if (node.id !== null) { return; } // If we have exceptions and the function is being invoked, detect whether we excepted it if (_this._allExceptItems && parentNode.type === 'CallExpression') { // Determine the path that resolves to our call expression // We must cover both direct calls (e.g. `it(function() {`) and // member expressions (e.g. `foo.bar(function() {`) var memberNode = parentNode.callee; var canBeRepresented = true; var fullpathParts = []; while (memberNode) { if (memberNode.type.match(/Identifier|Literal/)) { fullpathParts.unshift(getNodeName(memberNode)); } else if (memberNode.type === 'MemberExpression') { fullpathParts.unshift(getNodeName(memberNode.property)); } else { canBeRepresented = false; break; } memberNode = memberNode.object; } // If the path is not-dynamic (i.e. can be represented by static parts), // then check it against our exceptions if (canBeRepresented) { var fullpath = JSON.stringify(fullpathParts); for (var i = 0, l = _this._allExceptItems.length; i < l; i++) { if (fullpath === _this._allExceptItems[i]) { return; } } } } // Complain that this function must be named errors.add('Inline functions need to be named', node.loc.start); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (parentNode.type.match(/VariableDeclarator|Property|AssignmentExpression/)) {··· return; } |
| ✓ Negative was executed (else) | }··· // If the function has been named, skip it |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.id !== null) {··· return; } |
| ✓ Negative was executed (else) | }··· // If we have exceptions and the function is being invoked, detect whether we excepted it |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (_this._allExceptItems && parentNode.type === 'CallExpression') {··· // Determine the path that resolves to our call expression // We must cover both direct calls (e.g. `it(function() {`) and // member expressions (e.g. `foo.bar(function() {`) var memberNode = parentNode.callee; var canBeRepresented = true; var fullpathParts = []; while (memberNode) { if (memberNode.type.match(/Identifier|Literal/)) { fullpathParts.unshift(getNodeName(memberNode)); } else if (memberNode.type === 'MemberExpression') { fullpathParts.unshift(getNodeName(memberNode.property)); } else { canBeRepresented = false; break; } memberNode = memberNode.object; } // If the path is not-dynamic (i.e. can be represented by static parts), // then check it against our exceptions if (canBeRepresented) { var fullpath = JSON.stringify(fullpathParts); for (var i = 0, l = _this._allExceptItems.length; i < l; i++) { if (fullpath === _this._allExceptItems[i]) { return; } } } } |
| ✓ Negative was executed (else) | }··· // Complain that this function must be named |
| Branch LogicalExpression | |
| ✓ Was returned | if (_this._allExceptItems && parentNode.type === 'CallExpression') { |
| ✓ Was returned | if (_this._allExceptItems && parentNode.type === 'CallExpression') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (memberNode.type.match(/Identifier|Literal/)) {··· fullpathParts.unshift(getNodeName(memberNode)); } else if (memberNode.type === 'MemberExpression') { |
| ✓ Negative was executed (else) | } else if (memberNode.type === 'MemberExpression') {··· fullpathParts.unshift(getNodeName(memberNode.property)); } else { canBeRepresented = false; break; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (memberNode.type === 'MemberExpression') {··· fullpathParts.unshift(getNodeName(memberNode.property)); } else { |
| ✓ Negative was executed (else) | } else {··· canBeRepresented = false; break; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (canBeRepresented) {··· var fullpath = JSON.stringify(fullpathParts); for (var i = 0, l = _this._allExceptItems.length; i < l; i++) { if (fullpath === _this._allExceptItems[i]) { return; } } } |
| ✓ Negative was executed (else) | }··· } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (fullpath === _this._allExceptItems[i]) {··· return; } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_930) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_931) | |
|---|---|
| ✓ Was called | configure: function(settingValue) {··· assert( Array.isArray(settingValue) && settingValue.length || settingValue === true, 'requireNewlineBeforeBlockStatements option requires non-empty array value or true value' ); this._setting = settingValue; }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | Array.isArray(settingValue) && settingValue.length || settingValue === true, |
| ✓ Was returned | Array.isArray(settingValue) && settingValue.length || settingValue === true, |
| Branch LogicalExpression | |
| ✓ Was returned | Array.isArray(settingValue) && settingValue.length || settingValue === true, |
| ✓ Was returned | Array.isArray(settingValue) && settingValue.length || settingValue === true, |
| Function (anonymous_932) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireNewlineBeforeBlockStatements'; }, |
| Function (anonymous_933) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var setting = this._setting; function assertDifferentLine(token, nextToken) { errors.assert.differentLine({ token: token, nextToken: nextToken, message: 'Newline before curly brace for block statement is required' }); } file.iterateNodesByType('BlockStatement', function(node) { if (setting === true || setting.indexOf(getBlockType(node)) !== -1) { var openingBrace = file.getFirstNodeToken(node); var prevToken = file.getPrevToken(openingBrace); assertDifferentLine(prevToken, openingBrace); } }); if (setting === true || setting.indexOf('switch') !== -1) { file.iterateNodesByType(['SwitchStatement'], function(node) { var openingBrace = file.findNextToken(file.getLastNodeToken(node.discriminant), 'Punctuator', '{'); var prevToken = file.getPrevToken(openingBrace); assertDifferentLine(prevToken, openingBrace); }); } } |
| Function assertDifferentLine | |
|---|---|
| ✓ Was called | function assertDifferentLine(token, nextToken) {··· errors.assert.differentLine({ token: token, nextToken: nextToken, message: 'Newline before curly brace for block statement is required' }); } |
| Function (anonymous_935) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('BlockStatement', function(node) {··· if (setting === true || setting.indexOf(getBlockType(node)) !== -1) { var openingBrace = file.getFirstNodeToken(node); var prevToken = file.getPrevToken(openingBrace); assertDifferentLine(prevToken, openingBrace); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (setting === true || setting.indexOf(getBlockType(node)) !== -1) {··· var openingBrace = file.getFirstNodeToken(node); var prevToken = file.getPrevToken(openingBrace); assertDifferentLine(prevToken, openingBrace); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | if (setting === true || setting.indexOf(getBlockType(node)) !== -1) { |
| ✓ Was returned | if (setting === true || setting.indexOf(getBlockType(node)) !== -1) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (setting === true || setting.indexOf('switch') !== -1) {··· file.iterateNodesByType(['SwitchStatement'], function(node) { var openingBrace = file.findNextToken(file.getLastNodeToken(node.discriminant), 'Punctuator', '{'); var prevToken = file.getPrevToken(openingBrace); assertDifferentLine(prevToken, openingBrace); }); } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | if (setting === true || setting.indexOf('switch') !== -1) { |
| ✓ Was returned | if (setting === true || setting.indexOf('switch') !== -1) { |
| Function (anonymous_936) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['SwitchStatement'], function(node) {··· var openingBrace = file.findNextToken(file.getLastNodeToken(node.discriminant), 'Punctuator', '{'); var prevToken = file.getPrevToken(openingBrace); assertDifferentLine(prevToken, openingBrace); }); |
| Function getBlockType | |
|---|---|
| ✓ Was called | function getBlockType(node) {··· var parentNode = node.parentNode; switch (parentNode.type) { case 'IfStatement': return (parentNode.alternate === node) ? 'else' : 'if'; case 'FunctionDeclaration': case 'FunctionExpression': case 'ArrowFunctionExpression': return 'function'; case 'ForStatement': case 'ForInStatement': case 'ForOfStatement': return 'for'; case 'WhileStatement': return 'while'; case 'DoWhileStatement': return 'do'; case 'TryStatement': return (parentNode.finalizer === node) ? 'finally' : 'try'; case 'CatchClause': return 'catch'; } } |
| Branch SwitchStatement | |
|---|---|
| ✓ Was evaluated | case 'IfStatement':··· return (parentNode.alternate === node) ? 'else' : 'if'; |
| ✓ Was evaluated | case 'FunctionDeclaration': |
| ✓ Was evaluated | case 'FunctionExpression': |
| ✓ Was evaluated | case 'ArrowFunctionExpression':··· return 'function'; |
| ✓ Was evaluated | case 'ForStatement': |
| ✓ Was evaluated | case 'ForInStatement': |
| ✓ Was evaluated | case 'ForOfStatement':··· return 'for'; |
| ✓ Was evaluated | case 'WhileStatement':··· return 'while'; |
| ✓ Was evaluated | case 'DoWhileStatement':··· return 'do'; |
| ✓ Was evaluated | case 'TryStatement':··· return (parentNode.finalizer === node) ? 'finally' : 'try'; |
| ✓ Was evaluated | case 'CatchClause':··· return 'catch'; |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | return (parentNode.alternate === node) ? 'else' : 'if'; |
| ✓ Negative was returned (: ...) | return (parentNode.alternate === node) ? 'else' : 'if'; |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | return (parentNode.finalizer === node) ? 'finally' : 'try'; |
| ✓ Negative was returned (: ...) | return (parentNode.finalizer === node) ? 'finally' : 'try'; |
| Function (anonymous_938) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_939) | |
|---|---|
| ✓ Was called | configure: function(value) {··· assert( value === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_940) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireNewlineBeforeSingleStatementsInIf'; }, |
| Function (anonymous_941) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· function isExpressionStatement(entity) { return entity.type === 'ExpressionStatement'; } function assertDifferentLine(token, nextToken) { errors.assert.differentLine({ token: token, nextToken: nextToken, message: 'Newline before single statement in if is required' }); } file.iterateNodesByType('IfStatement', function(node) { var token; var consequentNode = node.consequent; var alternateNode = node.alternate; if (isExpressionStatement(consequentNode)) { token = file.getFirstNodeToken(consequentNode); assertDifferentLine( consequentNode, file.findPrevToken(token, 'Keyword') ); } if (isExpressionStatement(alternateNode)) { token = file.getFirstNodeToken(alternateNode); assertDifferentLine( alternateNode, file.findPrevToken(token, 'Keyword') ); } }); } |
| Function isExpressionStatement | |
|---|---|
| ✓ Was called | function isExpressionStatement(entity) {··· return entity.type === 'ExpressionStatement'; } |
| Function assertDifferentLine | |
|---|---|
| ✓ Was called | function assertDifferentLine(token, nextToken) {··· errors.assert.differentLine({ token: token, nextToken: nextToken, message: 'Newline before single statement in if is required' }); } |
| Function (anonymous_944) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('IfStatement', function(node) {··· var token; var consequentNode = node.consequent; var alternateNode = node.alternate; if (isExpressionStatement(consequentNode)) { token = file.getFirstNodeToken(consequentNode); assertDifferentLine( consequentNode, file.findPrevToken(token, 'Keyword') ); } if (isExpressionStatement(alternateNode)) { token = file.getFirstNodeToken(alternateNode); assertDifferentLine( alternateNode, file.findPrevToken(token, 'Keyword') ); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isExpressionStatement(consequentNode)) {··· token = file.getFirstNodeToken(consequentNode); assertDifferentLine( consequentNode, file.findPrevToken(token, 'Keyword') ); } |
| ✓ Negative was executed (else) | }··· if (isExpressionStatement(alternateNode)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isExpressionStatement(alternateNode)) {··· token = file.getFirstNodeToken(alternateNode); assertDifferentLine( alternateNode, file.findPrevToken(token, 'Keyword') ); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_945) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_946) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); this._radixMap = { 2: 'binary', 8: 'octal', 16: 'hexadecimal' }; }, |
| Function (anonymous_947) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireNumericLiterals'; }, |
| Function (anonymous_948) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var radixMap = this._radixMap; file.iterateNodesByType(['CallExpression'], function(node) { // don't check for parseInt(1) if (node.arguments.length !== 2) { return; } // only error if the radix is 2, 8, or 16 var radixName = radixMap[node.arguments[1].value]; if (node.callee.type === 'Identifier' && node.callee.name === 'parseInt' && radixName && node.arguments[0].type === 'Literal' ) { errors.add('Use ' + radixName + ' literals instead of parseInt', node.loc.start); } }); } |
| Function (anonymous_949) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['CallExpression'], function(node) {··· // don't check for parseInt(1) if (node.arguments.length !== 2) { return; } // only error if the radix is 2, 8, or 16 var radixName = radixMap[node.arguments[1].value]; if (node.callee.type === 'Identifier' && node.callee.name === 'parseInt' && radixName && node.arguments[0].type === 'Literal' ) { errors.add('Use ' + radixName + ' literals instead of parseInt', node.loc.start); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.arguments.length !== 2) {··· return; } |
| ✓ Negative was executed (else) | }··· // only error if the radix is 2, 8, or 16 |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | ) {··· errors.add('Use ' + radixName + ' literals instead of parseInt', node.loc.start); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | node.arguments[0].type === 'Literal' |
| ✓ Was returned | if (node.callee.type === 'Identifier' &&··· node.callee.name === 'parseInt' && radixName && |
| Branch LogicalExpression | |
| ✓ Was returned | radixName && |
| ✓ Was returned | if (node.callee.type === 'Identifier' &&··· node.callee.name === 'parseInt' && |
| Branch LogicalExpression | |
| ✓ Was returned | node.callee.name === 'parseInt' && |
| ✓ Was returned | if (node.callee.type === 'Identifier' && |
| Function (anonymous_950) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_951) | |
|---|---|
| ✓ Was called | configure: function(option) {··· var isTrue = option === true; assert( isTrue || (typeof option === 'object' && Array.isArray(option.allExcept)), this.getOptionName() + ' requires the value `true` ' + 'or an object with an `allExcept` array property' ); this._propertyExceptions = !isTrue && option.allExcept || []; }, |
| Branch LogicalExpression | |
|---|---|
| ✗ Was not returned | isTrue || (typeof option === 'object' && Array.isArray(option.allExcept)), |
| ✓ Was returned | isTrue || (typeof option === 'object' && Array.isArray(option.allExcept)), |
| Branch LogicalExpression | |
| ✗ Was not returned | isTrue || (typeof option === 'object' && Array.isArray(option.allExcept)), |
| ✗ Was not returned | isTrue || (typeof option === 'object' && Array.isArray(option.allExcept)), |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | this._propertyExceptions = !isTrue && option.allExcept || []; |
| ✗ Was not returned | this._propertyExceptions = !isTrue && option.allExcept || []; |
| Branch LogicalExpression | |
| ✗ Was not returned | this._propertyExceptions = !isTrue && option.allExcept || []; |
| ✓ Was returned | this._propertyExceptions = !isTrue && option.allExcept || []; |
| Function (anonymous_952) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireObjectDestructuring'; }, |
| Function (anonymous_953) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var propertyExceptions = this._propertyExceptions; file.iterateNodesByType('VariableDeclaration', function(node) { node.declarations.forEach(function(declaration) { var declarationId = declaration.id || {}; var declarationInit = declaration.init || {}; if (declarationId.type !== 'Identifier' || declarationInit.type !== 'MemberExpression') { return; } var propertyName = declarationInit.property && declarationInit.property.name; if (declarationId.name === propertyName && propertyExceptions.indexOf(propertyName) < 0) { errors.add('Property assignments should use destructuring', node.loc.start); } }); }); } |
| Function (anonymous_954) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('VariableDeclaration', function(node) {··· node.declarations.forEach(function(declaration) { var declarationId = declaration.id || {}; var declarationInit = declaration.init || {}; if (declarationId.type !== 'Identifier' || declarationInit.type !== 'MemberExpression') { return; } var propertyName = declarationInit.property && declarationInit.property.name; if (declarationId.name === propertyName && propertyExceptions.indexOf(propertyName) < 0) { errors.add('Property assignments should use destructuring', node.loc.start); } }); }); |
| Function (anonymous_955) | |
|---|---|
| ✓ Was called | node.declarations.forEach(function(declaration) {··· var declarationId = declaration.id || {}; var declarationInit = declaration.init || {}; if (declarationId.type !== 'Identifier' || declarationInit.type !== 'MemberExpression') { return; } var propertyName = declarationInit.property && declarationInit.property.name; if (declarationId.name === propertyName && propertyExceptions.indexOf(propertyName) < 0) { errors.add('Property assignments should use destructuring', node.loc.start); } }); |
| Branch LogicalExpression | |
|---|---|
| ✗ Was not returned | var declarationId = declaration.id || {}; |
| ✓ Was returned | var declarationId = declaration.id || {}; |
| Branch LogicalExpression | |
|---|---|
| ✗ Was not returned | var declarationInit = declaration.init || {}; |
| ✓ Was returned | var declarationInit = declaration.init || {}; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (declarationId.type !== 'Identifier' || declarationInit.type !== 'MemberExpression') {··· return; } |
| ✓ Negative was executed (else) | }··· var propertyName = declarationInit.property && declarationInit.property.name; |
| Branch LogicalExpression | |
| ✓ Was returned | if (declarationId.type !== 'Identifier' || declarationInit.type !== 'MemberExpression') { |
| ✓ Was returned | if (declarationId.type !== 'Identifier' || declarationInit.type !== 'MemberExpression') { |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | var propertyName = declarationInit.property && declarationInit.property.name; |
| ✗ Was not returned | var propertyName = declarationInit.property && declarationInit.property.name; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | propertyExceptions.indexOf(propertyName) < 0) {··· errors.add('Property assignments should use destructuring', node.loc.start); } |
| ✗ Negative was not executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | propertyExceptions.indexOf(propertyName) < 0) { |
| ✗ Was not returned | if (declarationId.name === propertyName && |
| Function (anonymous_956) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_957) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true || Array.isArray(options.allExcept), this.getOptionName() + ' option requires a true value or an object of exceptions' ); this._isSameLine = false; if (Array.isArray(options.allExcept)) { this._isSameLine = options.allExcept[0] === 'sameLine'; } }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options === true || Array.isArray(options.allExcept), |
| ✓ Was returned | options === true || Array.isArray(options.allExcept), |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (Array.isArray(options.allExcept)) {··· this._isSameLine = options.allExcept[0] === 'sameLine'; } |
| ✓ Negative was executed (else) | }··· }, |
| Function (anonymous_958) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireObjectKeysOnNewLine'; }, |
| Function (anonymous_959) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var message = 'Object keys must go on a new line'; var isSameLine = this._isSameLine; if (isSameLine) { message = 'Object keys must go on a new line if they aren\'t all on the same line'; } file.iterateNodesByType('ObjectExpression', function(node) { var firstKeyToken; var lastValueToken; if (isSameLine) { if (node.properties.length > 1) { firstKeyToken = file.getFirstNodeToken(node.properties[0].key); lastValueToken = file.getLastNodeToken(node.properties[node.properties.length - 1].value); if (firstKeyToken.loc.end.line === lastValueToken.loc.start.line) { // It's ok, all keys and values are on the same line. return; } } } for (var i = 1; i < node.properties.length; i++) { lastValueToken = file.getLastNodeToken(node.properties[i - 1].value); var comma = file.findNextToken(lastValueToken, 'Punctuator', ','); firstKeyToken = file.getFirstNodeToken(node.properties[i].key); errors.assert.differentLine({ token: comma, nextToken: firstKeyToken, message: message }); } }); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isSameLine) {··· message = 'Object keys must go on a new line if they aren\'t all on the same line'; } |
| ✓ Negative was executed (else) | }··· file.iterateNodesByType('ObjectExpression', function(node) { |
| Function (anonymous_960) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('ObjectExpression', function(node) {··· var firstKeyToken; var lastValueToken; if (isSameLine) { if (node.properties.length > 1) { firstKeyToken = file.getFirstNodeToken(node.properties[0].key); lastValueToken = file.getLastNodeToken(node.properties[node.properties.length - 1].value); if (firstKeyToken.loc.end.line === lastValueToken.loc.start.line) { // It's ok, all keys and values are on the same line. return; } } } for (var i = 1; i < node.properties.length; i++) { lastValueToken = file.getLastNodeToken(node.properties[i - 1].value); var comma = file.findNextToken(lastValueToken, 'Punctuator', ','); firstKeyToken = file.getFirstNodeToken(node.properties[i].key); errors.assert.differentLine({ token: comma, nextToken: firstKeyToken, message: message }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isSameLine) {··· if (node.properties.length > 1) { firstKeyToken = file.getFirstNodeToken(node.properties[0].key); lastValueToken = file.getLastNodeToken(node.properties[node.properties.length - 1].value); if (firstKeyToken.loc.end.line === lastValueToken.loc.start.line) { // It's ok, all keys and values are on the same line. return; } } } |
| ✓ Negative was executed (else) | }··· for (var i = 1; i < node.properties.length; i++) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.properties.length > 1) {··· firstKeyToken = file.getFirstNodeToken(node.properties[0].key); lastValueToken = file.getLastNodeToken(node.properties[node.properties.length - 1].value); if (firstKeyToken.loc.end.line === lastValueToken.loc.start.line) { // It's ok, all keys and values are on the same line. return; } } |
| ✓ Negative was executed (else) | }··· } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (firstKeyToken.loc.end.line === lastValueToken.loc.start.line) {··· // It's ok, all keys and values are on the same line. return; } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_961) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_962) | |
|---|---|
| ✓ Was called | configure: function(operators) {··· var isTrue = operators === true; assert( Array.isArray(operators) || isTrue, this.getOptionName() + ' option requires array value or true value' ); if (isTrue) { operators = defaultOperators; } this._operatorIndex = {}; for (var i = 0, l = operators.length; i < l; i++) { this._operatorIndex[operators[i]] = true; } }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | Array.isArray(operators) || isTrue, |
| ✓ Was returned | Array.isArray(operators) || isTrue, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isTrue) {··· operators = defaultOperators; } |
| ✓ Negative was executed (else) | }··· this._operatorIndex = {}; |
| Function (anonymous_963) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireOperatorBeforeLineBreak'; }, |
| Function (anonymous_964) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var operators = this._operatorIndex; var throughTokens = ['?', ',']; function errorIfApplicable(operatorToken) { errors.assert.sameLine({ token: file.getPrevToken(operatorToken), nextToken: operatorToken, message: 'Operator ' + operatorToken.value + ' should not be on a new line', stickToPreviousToken: true }); } throughTokens = throughTokens.filter(function(operator) { return operators[operator]; }); if (throughTokens.length) { file.iterateTokensByType('Punctuator', function(token) { var operator = token.value; if (throughTokens.every(function() { return throughTokens.indexOf(operator) >= 0; })) { errorIfApplicable(token); } }); } file.iterateNodesByType( ['BinaryExpression', 'AssignmentExpression', 'LogicalExpression'], function(node) { var operator = node.operator; if (!operators[operator]) { return; } var nextToken = file.getFirstNodeToken(node.argument || node.right); var token = file.findPrevOperatorToken(nextToken, operator); errorIfApplicable(token); } ); } |
| Function errorIfApplicable | |
|---|---|
| ✓ Was called | function errorIfApplicable(operatorToken) {··· errors.assert.sameLine({ token: file.getPrevToken(operatorToken), nextToken: operatorToken, message: 'Operator ' + operatorToken.value + ' should not be on a new line', stickToPreviousToken: true }); } |
| Function (anonymous_966) | |
|---|---|
| ✓ Was called | throughTokens = throughTokens.filter(function(operator) {··· return operators[operator]; }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (throughTokens.length) {··· file.iterateTokensByType('Punctuator', function(token) { var operator = token.value; if (throughTokens.every(function() { return throughTokens.indexOf(operator) >= 0; })) { errorIfApplicable(token); } }); } |
| ✓ Negative was executed (else) | }··· file.iterateNodesByType( |
| Function (anonymous_967) | |
|---|---|
| ✓ Was called | file.iterateTokensByType('Punctuator', function(token) {··· var operator = token.value; if (throughTokens.every(function() { return throughTokens.indexOf(operator) >= 0; })) { errorIfApplicable(token); } }); |
| Function (anonymous_968) | |
|---|---|
| ✓ Was called | if (throughTokens.every(function() {··· return throughTokens.indexOf(operator) >= 0; })) { |
| Branch IfStatement | |
| ✓ Positive was executed (if) | })) {··· errorIfApplicable(token); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_969) | |
|---|---|
| ✓ Was called | function(node) {··· var operator = node.operator; if (!operators[operator]) { return; } var nextToken = file.getFirstNodeToken(node.argument || node.right); var token = file.findPrevOperatorToken(nextToken, operator); errorIfApplicable(token); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!operators[operator]) {··· return; } |
| ✓ Negative was executed (else) | }··· var nextToken = file.getFirstNodeToken(node.argument || node.right); |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | var nextToken = file.getFirstNodeToken(node.argument || node.right); |
| ✗ Was not returned | var nextToken = file.getFirstNodeToken(node.argument || node.right); |
| Function (anonymous_970) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_971) | |
|---|---|
| ✓ Was called | configure: function(requirePaddingNewLineAfterVariableDeclaration) {··· assert( requirePaddingNewLineAfterVariableDeclaration === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_972) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requirePaddingNewLineAfterVariableDeclaration'; }, |
| Function (anonymous_973) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('VariableDeclaration', function(node) { if (node.parentNode.type === 'ForStatement' || node.parentNode.type === 'ForInStatement' || node.parentNode.type === 'ForOfStatement') { return; } var endOfDeclaration = file.getLastNodeToken(node); var nextToken = file.getNextToken(endOfDeclaration); // check export declaration if (nextToken.value === 'export') { nextToken = file.getNextToken(nextToken); } if (nextToken.value in {'var': true, 'let': true, 'const': true}) { return; } if (nextToken.value === '}') { return; } if (nextToken.type === 'EOF') { return; } errors.assert.linesBetween({ atLeast: 2, token: endOfDeclaration, nextToken: nextToken }); }); } |
| Function (anonymous_974) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('VariableDeclaration', function(node) {··· if (node.parentNode.type === 'ForStatement' || node.parentNode.type === 'ForInStatement' || node.parentNode.type === 'ForOfStatement') { return; } var endOfDeclaration = file.getLastNodeToken(node); var nextToken = file.getNextToken(endOfDeclaration); // check export declaration if (nextToken.value === 'export') { nextToken = file.getNextToken(nextToken); } if (nextToken.value in {'var': true, 'let': true, 'const': true}) { return; } if (nextToken.value === '}') { return; } if (nextToken.type === 'EOF') { return; } errors.assert.linesBetween({ atLeast: 2, token: endOfDeclaration, nextToken: nextToken }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | node.parentNode.type === 'ForOfStatement') {··· return; } |
| ✓ Negative was executed (else) | }··· var endOfDeclaration = file.getLastNodeToken(node); |
| Branch LogicalExpression | |
| ✓ Was returned | node.parentNode.type === 'ForOfStatement') { |
| ✓ Was returned | if (node.parentNode.type === 'ForStatement' ||··· node.parentNode.type === 'ForInStatement' || |
| Branch LogicalExpression | |
| ✓ Was returned | node.parentNode.type === 'ForInStatement' || |
| ✓ Was returned | if (node.parentNode.type === 'ForStatement' || |
| Branch IfStatement | |
|---|---|
| ✗ Positive was not executed (if) | if (nextToken.value === 'export') {··· nextToken = file.getNextToken(nextToken); } |
| ✓ Negative was executed (else) | }··· if (nextToken.value in {'var': true, 'let': true, 'const': true}) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (nextToken.value in {'var': true, 'let': true, 'const': true}) {··· return; } |
| ✓ Negative was executed (else) | }··· if (nextToken.value === '}') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (nextToken.value === '}') {··· return; } |
| ✓ Negative was executed (else) | }··· if (nextToken.type === 'EOF') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (nextToken.type === 'EOF') {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.linesBetween({ |
| Function isException | |
|---|---|
| ✓ Was called | function isException(parent, exceptions) {··· var grandpa = parent.parentNode; // Check if this block is used in call or array expression if (grandpa && exceptions[grandpa.type]) { return true; } return false; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (grandpa && exceptions[grandpa.type]) {··· return true; } |
| ✓ Negative was executed (else) | }··· return false; |
| Branch LogicalExpression | |
| ✓ Was returned | if (grandpa && exceptions[grandpa.type]) { |
| ✓ Was returned | if (grandpa && exceptions[grandpa.type]) { |
| Function (anonymous_976) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_977) | |
|---|---|
| ✓ Was called | configure: function(value) {··· this.exceptions = { 'CallExpression': false, 'NewExpression': false, 'ArrayExpression': false, 'Property': false }; var optionName = this.getOptionName(); if (typeof value === 'object') { assert(Array.isArray(value.allExcept), optionName + ' option requires "allExcept" ' + 'to be an array'); assert(value.allExcept.length > 0, optionName + ' option requires "allExcept" ' + 'to have at least one item or be set to `true`'); value.allExcept.forEach(function(except) { if (except === 'inCallExpressions') { this.exceptions.CallExpression = true; } else if (except === 'inNewExpressions') { this.exceptions.NewExpression = true; } else if (except === 'inArrayExpressions') { this.exceptions.ArrayExpression = true; } else if (except === 'inProperties') { this.exceptions.Property = true; } else { assert(false, optionName + ' option requires "allExcept" to only have ' + 'one of "inCallExpressions", "inNewExpressions", "inArrayExpressions" or "inProperties'); } }, this); } else { assert(value === true, optionName + ' option requires true value or object' ); } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof value === 'object') {··· assert(Array.isArray(value.allExcept), optionName + ' option requires "allExcept" ' + 'to be an array'); assert(value.allExcept.length > 0, optionName + ' option requires "allExcept" ' + 'to have at least one item or be set to `true`'); value.allExcept.forEach(function(except) { if (except === 'inCallExpressions') { this.exceptions.CallExpression = true; } else if (except === 'inNewExpressions') { this.exceptions.NewExpression = true; } else if (except === 'inArrayExpressions') { this.exceptions.ArrayExpression = true; } else if (except === 'inProperties') { this.exceptions.Property = true; } else { assert(false, optionName + ' option requires "allExcept" to only have ' + 'one of "inCallExpressions", "inNewExpressions", "inArrayExpressions" or "inProperties'); } }, this); } else { |
| ✓ Negative was executed (else) | } else {··· assert(value === true, optionName + ' option requires true value or object' ); } |
| Function (anonymous_978) | |
|---|---|
| ✓ Was called | value.allExcept.forEach(function(except) {··· if (except === 'inCallExpressions') { this.exceptions.CallExpression = true; } else if (except === 'inNewExpressions') { this.exceptions.NewExpression = true; } else if (except === 'inArrayExpressions') { this.exceptions.ArrayExpression = true; } else if (except === 'inProperties') { this.exceptions.Property = true; } else { assert(false, optionName + ' option requires "allExcept" to only have ' + 'one of "inCallExpressions", "inNewExpressions", "inArrayExpressions" or "inProperties'); } }, this); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (except === 'inCallExpressions') {··· this.exceptions.CallExpression = true; } else if (except === 'inNewExpressions') { |
| ✓ Negative was executed (else) | } else if (except === 'inNewExpressions') {··· this.exceptions.NewExpression = true; } else if (except === 'inArrayExpressions') { this.exceptions.ArrayExpression = true; } else if (except === 'inProperties') { this.exceptions.Property = true; } else { assert(false, optionName + ' option requires "allExcept" to only have ' + 'one of "inCallExpressions", "inNewExpressions", "inArrayExpressions" or "inProperties'); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (except === 'inNewExpressions') {··· this.exceptions.NewExpression = true; } else if (except === 'inArrayExpressions') { |
| ✓ Negative was executed (else) | } else if (except === 'inArrayExpressions') {··· this.exceptions.ArrayExpression = true; } else if (except === 'inProperties') { this.exceptions.Property = true; } else { assert(false, optionName + ' option requires "allExcept" to only have ' + 'one of "inCallExpressions", "inNewExpressions", "inArrayExpressions" or "inProperties'); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (except === 'inArrayExpressions') {··· this.exceptions.ArrayExpression = true; } else if (except === 'inProperties') { |
| ✓ Negative was executed (else) | } else if (except === 'inProperties') {··· this.exceptions.Property = true; } else { assert(false, optionName + ' option requires "allExcept" to only have ' + 'one of "inCallExpressions", "inNewExpressions", "inArrayExpressions" or "inProperties'); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (except === 'inProperties') {··· this.exceptions.Property = true; } else { |
| ✓ Negative was executed (else) | } else {··· assert(false, optionName + ' option requires "allExcept" to only have ' + 'one of "inCallExpressions", "inNewExpressions", "inArrayExpressions" or "inProperties'); } |
| Function (anonymous_979) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requirePaddingNewLinesAfterBlocks'; }, |
| Function (anonymous_980) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('BlockStatement', (function(node) { var endToken = file.getLastNodeToken(node); var parentNode = node.parentNode; if (isException(parentNode, this.exceptions)) { return; } var nextToken = file.getNextToken(endToken); while (nextToken.type !== 'EOF') { var excludeValues = excludes[parentNode.type]; if (excludeValues && excludeValues.indexOf(nextToken.value) !== -1) { return; } if (endToken.loc.end.line === nextToken.loc.start.line) { endToken = nextToken; nextToken = file.getNextToken(nextToken); continue; } if (nextToken.type === 'Punctuator' && ( nextToken.value === '}' || nextToken.value === ']' || nextToken.value === '>' || nextToken.value === ')') ) { return; } errors.assert.linesBetween({ token: endToken, nextToken: nextToken, atLeast: 2, message: 'Missing newline after block' }); return; } }).bind(this)); } |
| Function (anonymous_981) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('BlockStatement', (function(node) {··· var endToken = file.getLastNodeToken(node); var parentNode = node.parentNode; if (isException(parentNode, this.exceptions)) { return; } var nextToken = file.getNextToken(endToken); while (nextToken.type !== 'EOF') { var excludeValues = excludes[parentNode.type]; if (excludeValues && excludeValues.indexOf(nextToken.value) !== -1) { return; } if (endToken.loc.end.line === nextToken.loc.start.line) { endToken = nextToken; nextToken = file.getNextToken(nextToken); continue; } if (nextToken.type === 'Punctuator' && ( nextToken.value === '}' || nextToken.value === ']' || nextToken.value === '>' || nextToken.value === ')') ) { return; } errors.assert.linesBetween({ token: endToken, nextToken: nextToken, atLeast: 2, message: 'Missing newline after block' }); return; } }).bind(this)); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isException(parentNode, this.exceptions)) {··· return; } |
| ✓ Negative was executed (else) | }··· var nextToken = file.getNextToken(endToken); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (excludeValues && excludeValues.indexOf(nextToken.value) !== -1) {··· return; } |
| ✓ Negative was executed (else) | }··· if (endToken.loc.end.line === nextToken.loc.start.line) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (excludeValues && excludeValues.indexOf(nextToken.value) !== -1) { |
| ✗ Was not returned | if (excludeValues && excludeValues.indexOf(nextToken.value) !== -1) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (endToken.loc.end.line === nextToken.loc.start.line) {··· endToken = nextToken; nextToken = file.getNextToken(nextToken); continue; } |
| ✓ Negative was executed (else) | }··· if (nextToken.type === 'Punctuator' && ( |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | ) {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.linesBetween({ |
| Branch LogicalExpression | |
| ✓ Was returned | nextToken.value === '}' ||··· nextToken.value === ']' || nextToken.value === '>' || nextToken.value === ')') |
| ✓ Was returned | if (nextToken.type === 'Punctuator' && ( |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | nextToken.value === ')') |
| ✓ Was returned | nextToken.value === '}' ||··· nextToken.value === ']' || nextToken.value === '>' || |
| Branch LogicalExpression | |
| ✓ Was returned | nextToken.value === '>' || |
| ✓ Was returned | nextToken.value === '}' ||··· nextToken.value === ']' || |
| Branch LogicalExpression | |
| ✓ Was returned | nextToken.value === ']' || |
| ✓ Was returned | nextToken.value === '}' || |
| Function (anonymous_982) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_983) | |
|---|---|
| ✓ Was called | configure: function(options) {··· if (typeof options !== 'object') { assert( options === true, this.getOptionName() + ' option requires either a true value or an object' ); var _options = {allExcept: []}; return this.configure(_options); } if (Array.isArray(options.allExcept)) { this._exceptRequire = options.allExcept.indexOf('require') > -1; } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof options !== 'object') {··· assert( options === true, this.getOptionName() + ' option requires either a true value or an object' ); var _options = {allExcept: []}; return this.configure(_options); } |
| ✓ Negative was executed (else) | }··· if (Array.isArray(options.allExcept)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (Array.isArray(options.allExcept)) {··· this._exceptRequire = options.allExcept.indexOf('require') > -1; } |
| ✗ Negative was not executed (else) | }··· }, |
| Function (anonymous_984) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requirePaddingNewLinesAfterUseStrict'; }, |
| Function (anonymous_985) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var exceptRequire = this._exceptRequire; file.iterateNodesByType('ExpressionStatement', function(node) { var expression = node.expression; if (expression.type !== 'Literal' || expression.value !== 'use strict') { return; } var endOfNode = file.getLastNodeToken(node); if (exceptRequire) { var requireToken = file.findNextToken(endOfNode, 'Identifier', 'require'); if (requireToken && node.loc.start.line + 1 === requireToken.loc.start.line) { // Ensure the detected require is the first declaration of this line var keywordToken = file.getNextToken(endOfNode, { includeComments: true }); var identifierToken = file.getNextToken(file.getLastNodeToken(keywordToken), { includeComments: true }); var punctuatorToken = file.getNextToken(file.getLastNodeToken(identifierToken), { includeComments: true }); requireToken = file.getNextToken(file.getLastNodeToken(punctuatorToken), { includeComments: true }); if ( keywordToken.type === 'Keyword' && identifierToken.type === 'Identifier' && punctuatorToken.type === 'Punctuator' && requireToken.type === 'Identifier' && requireToken.value === 'require' ) { return; } } } var nextToken = file.getNextToken(endOfNode, { includeComments: true }); errors.assert.linesBetween({ atLeast: 2, token: endOfNode, nextToken: nextToken }); }); } |
| Function (anonymous_986) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('ExpressionStatement', function(node) {··· var expression = node.expression; if (expression.type !== 'Literal' || expression.value !== 'use strict') { return; } var endOfNode = file.getLastNodeToken(node); if (exceptRequire) { var requireToken = file.findNextToken(endOfNode, 'Identifier', 'require'); if (requireToken && node.loc.start.line + 1 === requireToken.loc.start.line) { // Ensure the detected require is the first declaration of this line var keywordToken = file.getNextToken(endOfNode, { includeComments: true }); var identifierToken = file.getNextToken(file.getLastNodeToken(keywordToken), { includeComments: true }); var punctuatorToken = file.getNextToken(file.getLastNodeToken(identifierToken), { includeComments: true }); requireToken = file.getNextToken(file.getLastNodeToken(punctuatorToken), { includeComments: true }); if ( keywordToken.type === 'Keyword' && identifierToken.type === 'Identifier' && punctuatorToken.type === 'Punctuator' && requireToken.type === 'Identifier' && requireToken.value === 'require' ) { return; } } } var nextToken = file.getNextToken(endOfNode, { includeComments: true }); errors.assert.linesBetween({ atLeast: 2, token: endOfNode, nextToken: nextToken }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (expression.type !== 'Literal' || expression.value !== 'use strict') {··· return; } |
| ✓ Negative was executed (else) | }··· var endOfNode = file.getLastNodeToken(node); |
| Branch LogicalExpression | |
| ✓ Was returned | if (expression.type !== 'Literal' || expression.value !== 'use strict') { |
| ✓ Was returned | if (expression.type !== 'Literal' || expression.value !== 'use strict') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (exceptRequire) {··· var requireToken = file.findNextToken(endOfNode, 'Identifier', 'require'); if (requireToken && node.loc.start.line + 1 === requireToken.loc.start.line) { // Ensure the detected require is the first declaration of this line var keywordToken = file.getNextToken(endOfNode, { includeComments: true }); var identifierToken = file.getNextToken(file.getLastNodeToken(keywordToken), { includeComments: true }); var punctuatorToken = file.getNextToken(file.getLastNodeToken(identifierToken), { includeComments: true }); requireToken = file.getNextToken(file.getLastNodeToken(punctuatorToken), { includeComments: true }); if ( keywordToken.type === 'Keyword' && identifierToken.type === 'Identifier' && punctuatorToken.type === 'Punctuator' && requireToken.type === 'Identifier' && requireToken.value === 'require' ) { return; } } } |
| ✓ Negative was executed (else) | }··· var nextToken = file.getNextToken(endOfNode, { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (requireToken && node.loc.start.line + 1 === requireToken.loc.start.line) {··· // Ensure the detected require is the first declaration of this line var keywordToken = file.getNextToken(endOfNode, { includeComments: true }); var identifierToken = file.getNextToken(file.getLastNodeToken(keywordToken), { includeComments: true }); var punctuatorToken = file.getNextToken(file.getLastNodeToken(identifierToken), { includeComments: true }); requireToken = file.getNextToken(file.getLastNodeToken(punctuatorToken), { includeComments: true }); if ( keywordToken.type === 'Keyword' && identifierToken.type === 'Identifier' && punctuatorToken.type === 'Punctuator' && requireToken.type === 'Identifier' && requireToken.value === 'require' ) { return; } } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | if (requireToken && node.loc.start.line + 1 === requireToken.loc.start.line) { |
| ✓ Was returned | if (requireToken && node.loc.start.line + 1 === requireToken.loc.start.line) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | ) {··· return; } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | requireToken.value === 'require' |
| ✓ Was returned | keywordToken.type === 'Keyword' &&··· identifierToken.type === 'Identifier' && punctuatorToken.type === 'Punctuator' && requireToken.type === 'Identifier' && |
| Branch LogicalExpression | |
| ✓ Was returned | requireToken.type === 'Identifier' && |
| ✗ Was not returned | keywordToken.type === 'Keyword' &&··· identifierToken.type === 'Identifier' && punctuatorToken.type === 'Punctuator' && |
| Branch LogicalExpression | |
| ✓ Was returned | punctuatorToken.type === 'Punctuator' && |
| ✗ Was not returned | keywordToken.type === 'Keyword' &&··· identifierToken.type === 'Identifier' && |
| Branch LogicalExpression | |
| ✓ Was returned | identifierToken.type === 'Identifier' && |
| ✗ Was not returned | keywordToken.type === 'Keyword' && |
| Function (anonymous_987) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_988) | |
|---|---|
| ✓ Was called | configure: function(value) {··· assert( value === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_989) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requirePaddingNewLinesBeforeExport'; }, |
| Function (anonymous_990) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('AssignmentExpression', function(node) { var left = node.left; var greatGrandpa = node.parentNode.parentNode; if (!( left.object && left.object.name === 'module' && left.property && left.property.name === 'exports')) { return; } // module.exports is in a block and is the only statement. if (greatGrandpa.type === 'BlockStatement' && greatGrandpa.body.length === 1) { return; } var firstToken = file.getFirstNodeToken(node); var prevToken = file.getPrevToken(firstToken); errors.assert.linesBetween({ atLeast: 2, token: prevToken, nextToken: firstToken, message: 'Missing newline before export' }); }); } |
| Function (anonymous_991) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('AssignmentExpression', function(node) {··· var left = node.left; var greatGrandpa = node.parentNode.parentNode; if (!( left.object && left.object.name === 'module' && left.property && left.property.name === 'exports')) { return; } // module.exports is in a block and is the only statement. if (greatGrandpa.type === 'BlockStatement' && greatGrandpa.body.length === 1) { return; } var firstToken = file.getFirstNodeToken(node); var prevToken = file.getPrevToken(firstToken); errors.assert.linesBetween({ atLeast: 2, token: prevToken, nextToken: firstToken, message: 'Missing newline before export' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | left.property.name === 'exports')) {··· return; } |
| ✓ Negative was executed (else) | }··· // module.exports is in a block and is the only statement. |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | left.property.name === 'exports')) { |
| ✓ Was returned | left.object &&··· left.object.name === 'module' && left.property && |
| Branch LogicalExpression | |
| ✓ Was returned | left.property && |
| ✓ Was returned | left.object &&··· left.object.name === 'module' && |
| Branch LogicalExpression | |
| ✓ Was returned | left.object.name === 'module' && |
| ✗ Was not returned | left.object && |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (greatGrandpa.type === 'BlockStatement' && greatGrandpa.body.length === 1) {··· return; } |
| ✓ Negative was executed (else) | }··· var firstToken = file.getFirstNodeToken(node); |
| Branch LogicalExpression | |
| ✓ Was returned | if (greatGrandpa.type === 'BlockStatement' && greatGrandpa.body.length === 1) { |
| ✓ Was returned | if (greatGrandpa.type === 'BlockStatement' && greatGrandpa.body.length === 1) { |
| Function (anonymous_992) | |
|---|---|
| ✓ Was called | module.exports = function() { }; |
| Function (anonymous_993) | |
|---|---|
| ✓ Was called | configure: function(keywords) {··· assert(Array.isArray(keywords) || keywords === true, this.getOptionName() + ' option requires array or true value'); if (keywords === true) { keywords = defaultKeywords; } this._keywords = keywords; }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | assert(Array.isArray(keywords) || keywords === true, |
| ✓ Was returned | assert(Array.isArray(keywords) || keywords === true, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (keywords === true) {··· keywords = defaultKeywords; } |
| ✓ Negative was executed (else) | }··· this._keywords = keywords; |
| Function (anonymous_994) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requirePaddingNewlinesBeforeKeywords'; }, |
| Function (anonymous_995) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var excludedTokens = [':', ',', '(', '=']; var specialCases = { 'if': 'else' }; file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) { var prevToken = file.getPrevToken(token); // Handle special cases listed in specialCasesToken array if (prevToken && prevToken.value === specialCases[token.value]) { return; // Allow returning a function } else if (prevToken && prevToken.value === 'return' && token.value === 'function') { return; } else if (prevToken && token.value === 'while' && file.getNodesByFirstToken(token).length === 0) { return; // Handle excludedTokens } else if (prevToken && excludedTokens.indexOf(prevToken.value) > -1) { return; } // Handle all other cases // The { character is there to handle the case of a matching token which happens to be the first // statement in a block // The ) character is there to handle the case of `if (...) matchingKeyword` in which case // requiring padding would break the statement if (prevToken && prevToken.value !== '{' && prevToken.value !== ')') { errors.assert.linesBetween({ token: prevToken, nextToken: token, atLeast: 2, message: 'Keyword `' + token.value + '` should have an empty line above it' }); } }); } |
| Function (anonymous_996) | |
|---|---|
| ✓ Was called | file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) {··· var prevToken = file.getPrevToken(token); // Handle special cases listed in specialCasesToken array if (prevToken && prevToken.value === specialCases[token.value]) { return; // Allow returning a function } else if (prevToken && prevToken.value === 'return' && token.value === 'function') { return; } else if (prevToken && token.value === 'while' && file.getNodesByFirstToken(token).length === 0) { return; // Handle excludedTokens } else if (prevToken && excludedTokens.indexOf(prevToken.value) > -1) { return; } // Handle all other cases // The { character is there to handle the case of a matching token which happens to be the first // statement in a block // The ) character is there to handle the case of `if (...) matchingKeyword` in which case // requiring padding would break the statement if (prevToken && prevToken.value !== '{' && prevToken.value !== ')') { errors.assert.linesBetween({ token: prevToken, nextToken: token, atLeast: 2, message: 'Keyword `' + token.value + '` should have an empty line above it' }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (prevToken && prevToken.value === specialCases[token.value]) {··· return; // Allow returning a function } else if (prevToken && prevToken.value === 'return' && token.value === 'function') { |
| ✓ Negative was executed (else) | } else if (prevToken && prevToken.value === 'return' && token.value === 'function') {··· return; } else if (prevToken && token.value === 'while' && file.getNodesByFirstToken(token).length === 0) { return; // Handle excludedTokens } else if (prevToken && excludedTokens.indexOf(prevToken.value) > -1) { return; } |
| Branch LogicalExpression | |
| ✓ Was returned | if (prevToken && prevToken.value === specialCases[token.value]) { |
| ✓ Was returned | if (prevToken && prevToken.value === specialCases[token.value]) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (prevToken && prevToken.value === 'return' && token.value === 'function') {··· return; } else if (prevToken && token.value === 'while' && |
| ✓ Negative was executed (else) | } else if (prevToken && token.value === 'while' &&··· file.getNodesByFirstToken(token).length === 0) { return; // Handle excludedTokens } else if (prevToken && excludedTokens.indexOf(prevToken.value) > -1) { return; } |
| Branch LogicalExpression | |
| ✓ Was returned | } else if (prevToken && prevToken.value === 'return' && token.value === 'function') { |
| ✓ Was returned | } else if (prevToken && prevToken.value === 'return' && token.value === 'function') { |
| Branch LogicalExpression | |
| ✓ Was returned | } else if (prevToken && prevToken.value === 'return' && token.value === 'function') { |
| ✓ Was returned | } else if (prevToken && prevToken.value === 'return' && token.value === 'function') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | file.getNodesByFirstToken(token).length === 0) {··· return; // Handle excludedTokens } else if (prevToken && excludedTokens.indexOf(prevToken.value) > -1) { |
| ✓ Negative was executed (else) | } else if (prevToken && excludedTokens.indexOf(prevToken.value) > -1) {··· return; } |
| Branch LogicalExpression | |
| ✓ Was returned | file.getNodesByFirstToken(token).length === 0) { |
| ✓ Was returned | } else if (prevToken && token.value === 'while' && |
| Branch LogicalExpression | |
| ✓ Was returned | } else if (prevToken && token.value === 'while' && |
| ✓ Was returned | } else if (prevToken && token.value === 'while' && |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (prevToken && excludedTokens.indexOf(prevToken.value) > -1) {··· return; } |
| ✓ Negative was executed (else) | }··· // Handle all other cases |
| Branch LogicalExpression | |
| ✓ Was returned | } else if (prevToken && excludedTokens.indexOf(prevToken.value) > -1) { |
| ✓ Was returned | } else if (prevToken && excludedTokens.indexOf(prevToken.value) > -1) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (prevToken && prevToken.value !== '{' && prevToken.value !== ')') {··· errors.assert.linesBetween({ token: prevToken, nextToken: token, atLeast: 2, message: 'Keyword `' + token.value + '` should have an empty line above it' }); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | if (prevToken && prevToken.value !== '{' && prevToken.value !== ')') { |
| ✓ Was returned | if (prevToken && prevToken.value !== '{' && prevToken.value !== ')') { |
| Branch LogicalExpression | |
| ✓ Was returned | if (prevToken && prevToken.value !== '{' && prevToken.value !== ')') { |
| ✓ Was returned | if (prevToken && prevToken.value !== '{' && prevToken.value !== ')') { |
| Function (anonymous_997) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_998) | |
|---|---|
| ✓ Was called | configure: function(value) {··· this._allowFirstAfterCurly = false; if (typeof value === 'object') { assert(typeof value.allExcept === 'string' && value.allExcept === 'firstAfterCurly', this.getOptionName() + ' option requires the "allExcept" ' + 'property to equal "firstAfterCurly"'); this._allowFirstAfterCurly = true; } else { assert(value === true, this.getOptionName() + ' option requires true value or object' ); } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof value === 'object') {··· assert(typeof value.allExcept === 'string' && value.allExcept === 'firstAfterCurly', this.getOptionName() + ' option requires the "allExcept" ' + 'property to equal "firstAfterCurly"'); this._allowFirstAfterCurly = true; } else { |
| ✓ Negative was executed (else) | } else {··· assert(value === true, this.getOptionName() + ' option requires true value or object' ); } |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | assert(typeof value.allExcept === 'string' && value.allExcept === 'firstAfterCurly', |
| ✓ Was returned | assert(typeof value.allExcept === 'string' && value.allExcept === 'firstAfterCurly', |
| Function (anonymous_999) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requirePaddingNewLinesBeforeLineComments'; }, |
| Function (anonymous_1000) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var allowFirstAfterCurly = this._allowFirstAfterCurly; file.iterateTokensByType('Line', function(comment) { if (comment.loc.start.line === 1) { return; } var firstToken = file.getFirstTokenOnLine(comment.loc.start.line); // Should not consider code and comment on the same line (#1194) if (firstToken !== null && firstToken.type !== 'EOF') { return; } var prevToken = file.getPrevToken(comment, {includeComments: true}); if (!prevToken || prevToken.type === 'Line') { return; } if (allowFirstAfterCurly && prevToken.type === 'Punctuator' && prevToken.value === '{') { return; } errors.assert.linesBetween({ token: prevToken, nextToken: comment, atLeast: 2, message: 'Line comments must be preceded with a blank line' }); }); } |
| Function (anonymous_1001) | |
|---|---|
| ✓ Was called | file.iterateTokensByType('Line', function(comment) {··· if (comment.loc.start.line === 1) { return; } var firstToken = file.getFirstTokenOnLine(comment.loc.start.line); // Should not consider code and comment on the same line (#1194) if (firstToken !== null && firstToken.type !== 'EOF') { return; } var prevToken = file.getPrevToken(comment, {includeComments: true}); if (!prevToken || prevToken.type === 'Line') { return; } if (allowFirstAfterCurly && prevToken.type === 'Punctuator' && prevToken.value === '{') { return; } errors.assert.linesBetween({ token: prevToken, nextToken: comment, atLeast: 2, message: 'Line comments must be preceded with a blank line' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (comment.loc.start.line === 1) {··· return; } |
| ✓ Negative was executed (else) | }··· var firstToken = file.getFirstTokenOnLine(comment.loc.start.line); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (firstToken !== null && firstToken.type !== 'EOF') {··· return; } |
| ✓ Negative was executed (else) | }··· var prevToken = file.getPrevToken(comment, {includeComments: true}); |
| Branch LogicalExpression | |
| ✓ Was returned | if (firstToken !== null && firstToken.type !== 'EOF') { |
| ✓ Was returned | if (firstToken !== null && firstToken.type !== 'EOF') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!prevToken || prevToken.type === 'Line') {··· return; } |
| ✓ Negative was executed (else) | }··· if (allowFirstAfterCurly && prevToken.type === 'Punctuator' && prevToken.value === '{') { |
| Branch LogicalExpression | |
| ✓ Was returned | if (!prevToken || prevToken.type === 'Line') { |
| ✓ Was returned | if (!prevToken || prevToken.type === 'Line') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (allowFirstAfterCurly && prevToken.type === 'Punctuator' && prevToken.value === '{') {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.linesBetween({ |
| Branch LogicalExpression | |
| ✓ Was returned | if (allowFirstAfterCurly && prevToken.type === 'Punctuator' && prevToken.value === '{') { |
| ✓ Was returned | if (allowFirstAfterCurly && prevToken.type === 'Punctuator' && prevToken.value === '{') { |
| Branch LogicalExpression | |
| ✓ Was returned | if (allowFirstAfterCurly && prevToken.type === 'Punctuator' && prevToken.value === '{') { |
| ✓ Was returned | if (allowFirstAfterCurly && prevToken.type === 'Punctuator' && prevToken.value === '{') { |
| Function (anonymous_1002) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1003) | |
|---|---|
| ✓ Was called | configure: function(options) {··· var optionName = this.getOptionName(); assert( options === true || typeof options === 'number' || typeof options === 'object', optionName + ' option requires the value true, an Integer or an object' ); this._checkOpen = true; this._checkClose = true; this._minLines = 0; if (typeof options === 'object') { assert(options.allExcept || options.open || options.close, optionName + 'option requires either "open", "close", "allExcept"'); if (options.allExcept) { assert(Array.isArray(options.allExcept), optionName + ' option requires "allExcept" to be an array'); assert(options.allExcept.length > 0, optionName + ' option requires "allExcept" to have at least one ' + 'item or be set to `true`'); this._exceptConditionals = options.allExcept.indexOf('conditionals') > -1; this._exceptFunctions = options.allExcept.indexOf('functions') > -1; } if (options.open || options.close) { assert(typeof options.open === 'boolean' && typeof options.close === 'boolean', this.getOptionName() + ' option requires the "open" and "close" ' + 'properties to be booleans'); this._checkOpen = options.open; this._checkClose = options.close; } } else if (typeof options === 'number') { this._minLines = options; } else { assert(options === true, this.getOptionName() + ' option requires either a true value, or an object'); } }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options === true || typeof options === 'number' || typeof options === 'object', |
| ✓ Was returned | options === true || typeof options === 'number' || typeof options === 'object', |
| Branch LogicalExpression | |
| ✓ Was returned | options === true || typeof options === 'number' || typeof options === 'object', |
| ✓ Was returned | options === true || typeof options === 'number' || typeof options === 'object', |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof options === 'object') {··· assert(options.allExcept || options.open || options.close, optionName + 'option requires either "open", "close", "allExcept"'); if (options.allExcept) { assert(Array.isArray(options.allExcept), optionName + ' option requires "allExcept" to be an array'); assert(options.allExcept.length > 0, optionName + ' option requires "allExcept" to have at least one ' + 'item or be set to `true`'); this._exceptConditionals = options.allExcept.indexOf('conditionals') > -1; this._exceptFunctions = options.allExcept.indexOf('functions') > -1; } if (options.open || options.close) { assert(typeof options.open === 'boolean' && typeof options.close === 'boolean', this.getOptionName() + ' option requires the "open" and "close" ' + 'properties to be booleans'); this._checkOpen = options.open; this._checkClose = options.close; } } else if (typeof options === 'number') { |
| ✓ Negative was executed (else) | } else if (typeof options === 'number') {··· this._minLines = options; } else { assert(options === true, this.getOptionName() + ' option requires either a true value, or an object'); } |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | assert(options.allExcept || options.open || options.close, |
| ✓ Was returned | assert(options.allExcept || options.open || options.close, |
| Branch LogicalExpression | |
| ✓ Was returned | assert(options.allExcept || options.open || options.close, |
| ✓ Was returned | assert(options.allExcept || options.open || options.close, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options.allExcept) {··· assert(Array.isArray(options.allExcept), optionName + ' option requires "allExcept" to be an array'); assert(options.allExcept.length > 0, optionName + ' option requires "allExcept" to have at least one ' + 'item or be set to `true`'); this._exceptConditionals = options.allExcept.indexOf('conditionals') > -1; this._exceptFunctions = options.allExcept.indexOf('functions') > -1; } |
| ✓ Negative was executed (else) | }··· if (options.open || options.close) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options.open || options.close) {··· assert(typeof options.open === 'boolean' && typeof options.close === 'boolean', this.getOptionName() + ' option requires the "open" and "close" ' + 'properties to be booleans'); this._checkOpen = options.open; this._checkClose = options.close; } |
| ✓ Negative was executed (else) | }··· } else if (typeof options === 'number') { |
| Branch LogicalExpression | |
| ✓ Was returned | if (options.open || options.close) { |
| ✓ Was returned | if (options.open || options.close) { |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | assert(typeof options.open === 'boolean' && typeof options.close === 'boolean', |
| ✓ Was returned | assert(typeof options.open === 'boolean' && typeof options.close === 'boolean', |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (typeof options === 'number') {··· this._minLines = options; } else { |
| ✓ Negative was executed (else) | } else {··· assert(options === true, this.getOptionName() + ' option requires either a true value, or an object'); } |
| Function (anonymous_1004) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requirePaddingNewlinesInBlocks'; }, |
| Function (anonymous_1005) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var minLines = this._minLines; var exceptConditionals = this._exceptConditionals; var exceptFunctions = this._exceptFunctions; var checkOpen = this._checkOpen; var checkClose = this._checkClose; file.iterateNodesByType('BlockStatement', function(node) { var openingBracket; var closingBracket; if (node.body.length <= minLines) { return; } if (exceptConditionals && node.parentNode.type === 'IfStatement' || exceptFunctions && (node.parentNode.type === 'FunctionExpression' || node.parentNode.type === 'FunctionDeclaration')) { return; } if (checkOpen === true) { openingBracket = file.getFirstNodeToken(node); errors.assert.linesBetween({ token: openingBracket, nextToken: file.getNextToken(openingBracket, {includeComments: true}), atLeast: 2, message: 'Expected a padding newline after opening curly brace' }); } if (checkClose === true) { closingBracket = file.getLastNodeToken(node); errors.assert.linesBetween({ token: file.getPrevToken(closingBracket, {includeComments: true}), nextToken: closingBracket, atLeast: 2, message: 'Expected a padding newline before closing curly brace' }); } }); } |
| Function (anonymous_1006) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('BlockStatement', function(node) {··· var openingBracket; var closingBracket; if (node.body.length <= minLines) { return; } if (exceptConditionals && node.parentNode.type === 'IfStatement' || exceptFunctions && (node.parentNode.type === 'FunctionExpression' || node.parentNode.type === 'FunctionDeclaration')) { return; } if (checkOpen === true) { openingBracket = file.getFirstNodeToken(node); errors.assert.linesBetween({ token: openingBracket, nextToken: file.getNextToken(openingBracket, {includeComments: true}), atLeast: 2, message: 'Expected a padding newline after opening curly brace' }); } if (checkClose === true) { closingBracket = file.getLastNodeToken(node); errors.assert.linesBetween({ token: file.getPrevToken(closingBracket, {includeComments: true}), nextToken: closingBracket, atLeast: 2, message: 'Expected a padding newline before closing curly brace' }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.body.length <= minLines) {··· return; } |
| ✓ Negative was executed (else) | }··· if (exceptConditionals && node.parentNode.type === 'IfStatement' || |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | node.parentNode.type === 'FunctionDeclaration')) {··· return; } |
| ✓ Negative was executed (else) | }··· if (checkOpen === true) { |
| Branch LogicalExpression | |
| ✓ Was returned | exceptFunctions && (node.parentNode.type === 'FunctionExpression' ||··· node.parentNode.type === 'FunctionDeclaration')) { |
| ✓ Was returned | if (exceptConditionals && node.parentNode.type === 'IfStatement' || |
| Branch LogicalExpression | |
| ✓ Was returned | if (exceptConditionals && node.parentNode.type === 'IfStatement' || |
| ✓ Was returned | if (exceptConditionals && node.parentNode.type === 'IfStatement' || |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | exceptFunctions && (node.parentNode.type === 'FunctionExpression' ||··· node.parentNode.type === 'FunctionDeclaration')) { |
| ✓ Was returned | exceptFunctions && (node.parentNode.type === 'FunctionExpression' || |
| Branch LogicalExpression | |
| ✓ Was returned | node.parentNode.type === 'FunctionDeclaration')) { |
| ✓ Was returned | exceptFunctions && (node.parentNode.type === 'FunctionExpression' || |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (checkOpen === true) {··· openingBracket = file.getFirstNodeToken(node); errors.assert.linesBetween({ token: openingBracket, nextToken: file.getNextToken(openingBracket, {includeComments: true}), atLeast: 2, message: 'Expected a padding newline after opening curly brace' }); } |
| ✓ Negative was executed (else) | }··· if (checkClose === true) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (checkClose === true) {··· closingBracket = file.getLastNodeToken(node); errors.assert.linesBetween({ token: file.getPrevToken(closingBracket, {includeComments: true}), nextToken: closingBracket, atLeast: 2, message: 'Expected a padding newline before closing curly brace' }); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_1007) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1008) | |
|---|---|
| ✓ Was called | configure: function(value) {··· assert( value === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_1009) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requirePaddingNewLinesInObjects'; }, |
| Function (anonymous_1010) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('ObjectExpression', function(node) { var openingBracket = file.getFirstNodeToken(node); var nextToken = file.getNextToken(openingBracket); if (nextToken.type === 'Punctuator' && nextToken.value === '}') { return; } errors.assert.differentLine({ token: openingBracket, nextToken: nextToken, message: 'Missing newline after opening curly brace' }); var closingBracket = file.getLastNodeToken(node); errors.assert.differentLine({ token: file.getPrevToken(closingBracket), nextToken: closingBracket, message: 'Missing newline before closing curly brace' }); }); } |
| Function (anonymous_1011) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('ObjectExpression', function(node) {··· var openingBracket = file.getFirstNodeToken(node); var nextToken = file.getNextToken(openingBracket); if (nextToken.type === 'Punctuator' && nextToken.value === '}') { return; } errors.assert.differentLine({ token: openingBracket, nextToken: nextToken, message: 'Missing newline after opening curly brace' }); var closingBracket = file.getLastNodeToken(node); errors.assert.differentLine({ token: file.getPrevToken(closingBracket), nextToken: closingBracket, message: 'Missing newline before closing curly brace' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (nextToken.type === 'Punctuator' && nextToken.value === '}') {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.differentLine({ |
| Branch LogicalExpression | |
| ✓ Was returned | if (nextToken.type === 'Punctuator' && nextToken.value === '}') { |
| ✓ Was returned | if (nextToken.type === 'Punctuator' && nextToken.value === '}') { |
| Function (anonymous_1012) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1013) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_1014) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireParenthesesAroundArrowParam'; }, |
| Function (anonymous_1015) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· function isWrapped(node) { var openParensToken = file.getPrevToken(file.getFirstNodeToken(node)); var closingParensToken = file.getNextToken(file.getLastNodeToken(node)); var closingTokenValue = closingParensToken ? closingParensToken.value : ''; return openParensToken.value + closingTokenValue === '()'; } file.iterateNodesByType('ArrowFunctionExpression', function(node) { var params = node.params; var firstParam = params[0]; if (params.length === 1 && !isWrapped(firstParam)) { errors.add( 'Wrap arrow function expressions in parentheses', firstParam.loc.start ); } }); } |
| Function isWrapped | |
|---|---|
| ✓ Was called | function isWrapped(node) {··· var openParensToken = file.getPrevToken(file.getFirstNodeToken(node)); var closingParensToken = file.getNextToken(file.getLastNodeToken(node)); var closingTokenValue = closingParensToken ? closingParensToken.value : ''; return openParensToken.value + closingTokenValue === '()'; } |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | var closingTokenValue = closingParensToken ? closingParensToken.value : ''; |
| ✗ Negative was not returned (: ...) | var closingTokenValue = closingParensToken ? closingParensToken.value : ''; |
| Function (anonymous_1017) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('ArrowFunctionExpression', function(node) {··· var params = node.params; var firstParam = params[0]; if (params.length === 1 && !isWrapped(firstParam)) { errors.add( 'Wrap arrow function expressions in parentheses', firstParam.loc.start ); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (params.length === 1 && !isWrapped(firstParam)) {··· errors.add( 'Wrap arrow function expressions in parentheses', firstParam.loc.start ); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | if (params.length === 1 && !isWrapped(firstParam)) { |
| ✓ Was returned | if (params.length === 1 && !isWrapped(firstParam)) { |
| Function (anonymous_1018) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1019) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_1020) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireParenthesesAroundIIFE'; }, |
| Function (anonymous_1021) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· function isWrapped(node) { var openParensToken = file.getPrevToken(file.getFirstNodeToken(node)); var closingParensToken = file.getNextToken(file.getLastNodeToken(node)); var closingTokenValue = closingParensToken ? closingParensToken.value : ''; return openParensToken.value + closingTokenValue === '()'; } file.iterateNodesByType('CallExpression', function(node) { var inner = utils.getFunctionNodeFromIIFE(node); if (inner && !isWrapped(inner) && !isWrapped(node)) { errors.add( 'Wrap immediately invoked function expressions in parentheses', node.loc.start.line, node.loc.start.column ); } }); } |
| Function isWrapped | |
|---|---|
| ✓ Was called | function isWrapped(node) {··· var openParensToken = file.getPrevToken(file.getFirstNodeToken(node)); var closingParensToken = file.getNextToken(file.getLastNodeToken(node)); var closingTokenValue = closingParensToken ? closingParensToken.value : ''; return openParensToken.value + closingTokenValue === '()'; } |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | var closingTokenValue = closingParensToken ? closingParensToken.value : ''; |
| ✗ Negative was not returned (: ...) | var closingTokenValue = closingParensToken ? closingParensToken.value : ''; |
| Function (anonymous_1023) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('CallExpression', function(node) {··· var inner = utils.getFunctionNodeFromIIFE(node); if (inner && !isWrapped(inner) && !isWrapped(node)) { errors.add( 'Wrap immediately invoked function expressions in parentheses', node.loc.start.line, node.loc.start.column ); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (inner && !isWrapped(inner) && !isWrapped(node)) {··· errors.add( 'Wrap immediately invoked function expressions in parentheses', node.loc.start.line, node.loc.start.column ); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | if (inner && !isWrapped(inner) && !isWrapped(node)) { |
| ✓ Was returned | if (inner && !isWrapped(inner) && !isWrapped(node)) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (inner && !isWrapped(inner) && !isWrapped(node)) { |
| ✓ Was returned | if (inner && !isWrapped(inner) && !isWrapped(node)) { |
| Function (anonymous_1024) | |
|---|---|
| ✓ Was called | module.exports = function() { }; |
| Function (anonymous_1025) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_1026) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireQuotedKeysInObjects'; }, |
| Function (anonymous_1027) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('ObjectExpression', function(node) { node.properties.forEach(function(property) { if (property.shorthand || property.method || property.kind !== 'init' || node.type === 'SpreadProperty') { return; } var key = property.key; if (!(typeof key.value === 'string' && key.type === 'Literal')) { errors.add('Object key without surrounding quotes', property.loc.start); } }); }); } |
| Function (anonymous_1028) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('ObjectExpression', function(node) {··· node.properties.forEach(function(property) { if (property.shorthand || property.method || property.kind !== 'init' || node.type === 'SpreadProperty') { return; } var key = property.key; if (!(typeof key.value === 'string' && key.type === 'Literal')) { errors.add('Object key without surrounding quotes', property.loc.start); } }); }); |
| Function (anonymous_1029) | |
|---|---|
| ✓ Was called | node.properties.forEach(function(property) {··· if (property.shorthand || property.method || property.kind !== 'init' || node.type === 'SpreadProperty') { return; } var key = property.key; if (!(typeof key.value === 'string' && key.type === 'Literal')) { errors.add('Object key without surrounding quotes', property.loc.start); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | node.type === 'SpreadProperty') {··· return; } |
| ✓ Negative was executed (else) | }··· var key = property.key; |
| Branch LogicalExpression | |
| ✓ Was returned | node.type === 'SpreadProperty') { |
| ✓ Was returned | if (property.shorthand || property.method || property.kind !== 'init' || |
| Branch LogicalExpression | |
| ✓ Was returned | if (property.shorthand || property.method || property.kind !== 'init' || |
| ✓ Was returned | if (property.shorthand || property.method || property.kind !== 'init' || |
| Branch LogicalExpression | |
| ✓ Was returned | if (property.shorthand || property.method || property.kind !== 'init' || |
| ✓ Was returned | if (property.shorthand || property.method || property.kind !== 'init' || |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!(typeof key.value === 'string' && key.type === 'Literal')) {··· errors.add('Object key without surrounding quotes', property.loc.start); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | if (!(typeof key.value === 'string' && key.type === 'Literal')) { |
| ✓ Was returned | if (!(typeof key.value === 'string' && key.type === 'Literal')) { |
| Function (anonymous_1030) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1031) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_1032) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSemicolons'; }, |
| Function (anonymous_1033) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType([ 'VariableDeclaration', 'ImportDeclaration', 'ExportDeclaration', 'ExportDefaultDeclaration', 'ExportNamedDeclaration', 'ExpressionStatement', 'DoWhileStatement', 'ReturnStatement', 'ThrowStatement', 'BreakStatement', 'ContinueStatement', 'DebuggerStatement', 'ClassProperty' ], function(node) { // ignore variable declaration inside for and for-in if (node.type === 'VariableDeclaration') { if ((node.parentNode.type === 'ForInStatement' && node.parentNode.left === node) || (node.parentNode.type === 'ForOfStatement' && node.parentNode.left === node) || (node.parentNode.type === 'ForStatement' && node.parentNode.init === node)) { return; } } // don't require semicolon for class and function exports if (node.type === 'ExportDefaultDeclaration' || node.type === 'ExportNamedDeclaration') { if (node.declaration) { if (node.declaration.type === 'ClassDeclaration' || node.declaration.type === 'FunctionDeclaration') { return; } } } // get last token inside node var lastToken = file.getLastNodeToken(node); var checkToken = lastToken; // if last token is not a semicolon punctuator, try to get next token in file if (checkToken && (checkToken.type !== 'Punctuator' || checkToken.value !== ';')) { checkToken = file.getNextToken(checkToken); } // check token is semicolon if (!checkToken || checkToken.type !== 'Punctuator' || checkToken.value !== ';') { var entity = lastToken || node; errors.cast({ message: 'Missing semicolon after statement', line: entity.loc.end.line, column: entity.loc.end.column, additional: entity }); } }); }, |
| Function (anonymous_1034) | |
|---|---|
| ✓ Was called | ], function(node) {··· // ignore variable declaration inside for and for-in if (node.type === 'VariableDeclaration') { if ((node.parentNode.type === 'ForInStatement' && node.parentNode.left === node) || (node.parentNode.type === 'ForOfStatement' && node.parentNode.left === node) || (node.parentNode.type === 'ForStatement' && node.parentNode.init === node)) { return; } } // don't require semicolon for class and function exports if (node.type === 'ExportDefaultDeclaration' || node.type === 'ExportNamedDeclaration') { if (node.declaration) { if (node.declaration.type === 'ClassDeclaration' || node.declaration.type === 'FunctionDeclaration') { return; } } } // get last token inside node var lastToken = file.getLastNodeToken(node); var checkToken = lastToken; // if last token is not a semicolon punctuator, try to get next token in file if (checkToken && (checkToken.type !== 'Punctuator' || checkToken.value !== ';')) { checkToken = file.getNextToken(checkToken); } // check token is semicolon if (!checkToken || checkToken.type !== 'Punctuator' || checkToken.value !== ';') { var entity = lastToken || node; errors.cast({ message: 'Missing semicolon after statement', line: entity.loc.end.line, column: entity.loc.end.column, additional: entity }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.type === 'VariableDeclaration') {··· if ((node.parentNode.type === 'ForInStatement' && node.parentNode.left === node) || (node.parentNode.type === 'ForOfStatement' && node.parentNode.left === node) || (node.parentNode.type === 'ForStatement' && node.parentNode.init === node)) { return; } } |
| ✓ Negative was executed (else) | }··· // don't require semicolon for class and function exports |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | (node.parentNode.type === 'ForStatement' && node.parentNode.init === node)) {··· return; } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | (node.parentNode.type === 'ForStatement' && node.parentNode.init === node)) { |
| ✓ Was returned | if ((node.parentNode.type === 'ForInStatement' && node.parentNode.left === node) ||··· (node.parentNode.type === 'ForOfStatement' && node.parentNode.left === node) || |
| Branch LogicalExpression | |
| ✓ Was returned | (node.parentNode.type === 'ForOfStatement' && node.parentNode.left === node) || |
| ✓ Was returned | if ((node.parentNode.type === 'ForInStatement' && node.parentNode.left === node) || |
| Branch LogicalExpression | |
| ✓ Was returned | if ((node.parentNode.type === 'ForInStatement' && node.parentNode.left === node) || |
| ✓ Was returned | if ((node.parentNode.type === 'ForInStatement' && node.parentNode.left === node) || |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | (node.parentNode.type === 'ForOfStatement' && node.parentNode.left === node) || |
| ✓ Was returned | (node.parentNode.type === 'ForOfStatement' && node.parentNode.left === node) || |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | (node.parentNode.type === 'ForStatement' && node.parentNode.init === node)) { |
| ✓ Was returned | (node.parentNode.type === 'ForStatement' && node.parentNode.init === node)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | node.type === 'ExportNamedDeclaration') {··· if (node.declaration) { if (node.declaration.type === 'ClassDeclaration' || node.declaration.type === 'FunctionDeclaration') { return; } } } |
| ✓ Negative was executed (else) | }··· // get last token inside node |
| Branch LogicalExpression | |
| ✓ Was returned | node.type === 'ExportNamedDeclaration') { |
| ✓ Was returned | if (node.type === 'ExportDefaultDeclaration' || |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.declaration) {··· if (node.declaration.type === 'ClassDeclaration' || node.declaration.type === 'FunctionDeclaration') { return; } } |
| ✓ Negative was executed (else) | }··· } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | node.declaration.type === 'FunctionDeclaration') {··· return; } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | node.declaration.type === 'FunctionDeclaration') { |
| ✓ Was returned | if (node.declaration.type === 'ClassDeclaration' || |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (checkToken && (checkToken.type !== 'Punctuator' || checkToken.value !== ';')) {··· checkToken = file.getNextToken(checkToken); } |
| ✓ Negative was executed (else) | }··· // check token is semicolon |
| Branch LogicalExpression | |
| ✓ Was returned | if (checkToken && (checkToken.type !== 'Punctuator' || checkToken.value !== ';')) { |
| ✗ Was not returned | if (checkToken && (checkToken.type !== 'Punctuator' || checkToken.value !== ';')) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (checkToken && (checkToken.type !== 'Punctuator' || checkToken.value !== ';')) { |
| ✓ Was returned | if (checkToken && (checkToken.type !== 'Punctuator' || checkToken.value !== ';')) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!checkToken || checkToken.type !== 'Punctuator' || checkToken.value !== ';') {··· var entity = lastToken || node; errors.cast({ message: 'Missing semicolon after statement', line: entity.loc.end.line, column: entity.loc.end.column, additional: entity }); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | if (!checkToken || checkToken.type !== 'Punctuator' || checkToken.value !== ';') { |
| ✓ Was returned | if (!checkToken || checkToken.type !== 'Punctuator' || checkToken.value !== ';') { |
| Branch LogicalExpression | |
| ✓ Was returned | if (!checkToken || checkToken.type !== 'Punctuator' || checkToken.value !== ';') { |
| ✗ Was not returned | if (!checkToken || checkToken.type !== 'Punctuator' || checkToken.value !== ';') { |
| Branch LogicalExpression | |
|---|---|
| ✗ Was not returned | var entity = lastToken || node; |
| ✓ Was returned | var entity = lastToken || node; |
| Function (anonymous_1035) | |
|---|---|
| ✓ Was called | _fix: function(file, error) {··· var token; var entity = error.additional; var isNode = !!entity.parentNode; if (isNode) { token = file.getLastNodeToken(entity.parentNode); } else { token = file.getNextToken(entity, { includeComments: true }); } file.setWhitespaceBefore(token, ';' + file.getWhitespaceBefore(token)); } |
| Branch IfStatement | |
|---|---|
| ✗ Positive was not executed (if) | if (isNode) {··· token = file.getLastNodeToken(entity.parentNode); } else { |
| ✓ Negative was executed (else) | } else {··· token = file.getNextToken(entity, { includeComments: true }); } |
| Function (anonymous_1036) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1037) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_1038) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireShorthandArrowFunctions'; }, |
| Function (anonymous_1039) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('ArrowFunctionExpression', function(node) { var body = node.body; if (body.type === 'BlockStatement' && body.body.length === 1 && body.body[0].type === 'ReturnStatement') { errors.add( 'Use the shorthand arrow function form', node.body.loc.start ); } }); } |
| Function (anonymous_1040) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('ArrowFunctionExpression', function(node) {··· var body = node.body; if (body.type === 'BlockStatement' && body.body.length === 1 && body.body[0].type === 'ReturnStatement') { errors.add( 'Use the shorthand arrow function form', node.body.loc.start ); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | body.body[0].type === 'ReturnStatement') {··· errors.add( 'Use the shorthand arrow function form', node.body.loc.start ); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | body.body[0].type === 'ReturnStatement') { |
| ✓ Was returned | if (body.type === 'BlockStatement' &&··· body.body.length === 1 && |
| Branch LogicalExpression | |
| ✓ Was returned | body.body.length === 1 && |
| ✓ Was returned | if (body.type === 'BlockStatement' && |
| Function (anonymous_1041) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1042) | |
|---|---|
| ✓ Was called | configure: function(operators) {··· var isTrue = operators === true; assert( Array.isArray(operators) || isTrue, this.getOptionName() + ' option requires array or true value' ); if (isTrue) { operators = allOperators; } this._operatorIndex = {}; for (var i = 0, l = operators.length; i < l; i++) { this._operatorIndex[operators[i]] = true; } }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | Array.isArray(operators) || isTrue, |
| ✓ Was returned | Array.isArray(operators) || isTrue, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isTrue) {··· operators = allOperators; } |
| ✓ Negative was executed (else) | }··· this._operatorIndex = {}; |
| Function (anonymous_1043) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpaceAfterBinaryOperators'; }, |
| Function (anonymous_1044) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var operators = this._operatorIndex; // Comma if (operators[',']) { file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { errors.assert.whitespaceBetween({ token: token, nextToken: file.getNextToken(token), message: 'Operator , should not stick to following expression' }); }); } // For everything else file.iterateNodesByType( ['BinaryExpression', 'AssignmentExpression', 'VariableDeclarator', 'LogicalExpression'], function(node) { var operator; var expression; if (node.type === 'VariableDeclarator') { expression = node.init; operator = '='; } else { operator = node.operator; expression = node.right; } if (expression === null) { return; } var operatorToken = file.findPrevOperatorToken( file.getFirstNodeToken(expression), operator ); var nextToken = file.getNextToken(operatorToken); if (operators[operator]) { errors.assert.whitespaceBetween({ token: operatorToken, nextToken: nextToken, message: 'Operator ' + operator + ' should not stick to following expression' }); } } ); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (operators[',']) {··· file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { errors.assert.whitespaceBetween({ token: token, nextToken: file.getNextToken(token), message: 'Operator , should not stick to following expression' }); }); } |
| ✓ Negative was executed (else) | }··· // For everything else |
| Function (anonymous_1045) | |
|---|---|
| ✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) {··· errors.assert.whitespaceBetween({ token: token, nextToken: file.getNextToken(token), message: 'Operator , should not stick to following expression' }); }); |
| Function (anonymous_1046) | |
|---|---|
| ✓ Was called | function(node) {··· var operator; var expression; if (node.type === 'VariableDeclarator') { expression = node.init; operator = '='; } else { operator = node.operator; expression = node.right; } if (expression === null) { return; } var operatorToken = file.findPrevOperatorToken( file.getFirstNodeToken(expression), operator ); var nextToken = file.getNextToken(operatorToken); if (operators[operator]) { errors.assert.whitespaceBetween({ token: operatorToken, nextToken: nextToken, message: 'Operator ' + operator + ' should not stick to following expression' }); } } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.type === 'VariableDeclarator') {··· expression = node.init; operator = '='; } else { |
| ✓ Negative was executed (else) | } else {··· operator = node.operator; expression = node.right; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (expression === null) {··· return; } |
| ✓ Negative was executed (else) | }··· var operatorToken = file.findPrevOperatorToken( |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (operators[operator]) {··· errors.assert.whitespaceBetween({ token: operatorToken, nextToken: nextToken, message: 'Operator ' + operator + ' should not stick to following expression' }); } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_1047) | |
|---|---|
| ✓ Was called | module.exports = function() {··· }; |
| Function (anonymous_1048) | |
|---|---|
| ✓ Was called | configure: function(options) {··· if (typeof options !== 'object') { assert( options === true, this.getOptionName() + ' option requires true value or an object' ); var _options = {allExcept: []}; return this.configure(_options); } assert( Array.isArray(options.allExcept), ' property `allExcept` in ' + this.getOptionName() + ' should be an array of strings' ); this._exceptTrailingCommas = options.allExcept.indexOf('trailing') >= 0; }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof options !== 'object') {··· assert( options === true, this.getOptionName() + ' option requires true value or an object' ); var _options = {allExcept: []}; return this.configure(_options); } |
| ✓ Negative was executed (else) | }··· assert( |
| Function (anonymous_1049) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpaceAfterComma'; }, |
| Function (anonymous_1050) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var exceptTrailingCommas = this._exceptTrailingCommas; file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { if (exceptTrailingCommas && [']', '}'].indexOf(file.getNextToken(token).value) >= 0) { return; } errors.assert.whitespaceBetween({ token: token, nextToken: file.getNextToken(token), message: 'Space required after comma' }); }); } |
| Function (anonymous_1051) | |
|---|---|
| ✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) {··· if (exceptTrailingCommas && [']', '}'].indexOf(file.getNextToken(token).value) >= 0) { return; } errors.assert.whitespaceBetween({ token: token, nextToken: file.getNextToken(token), message: 'Space required after comma' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (exceptTrailingCommas && [']', '}'].indexOf(file.getNextToken(token).value) >= 0) {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.whitespaceBetween({ |
| Branch LogicalExpression | |
| ✓ Was returned | if (exceptTrailingCommas && [']', '}'].indexOf(file.getNextToken(token).value) >= 0) { |
| ✓ Was returned | if (exceptTrailingCommas && [']', '}'].indexOf(file.getNextToken(token).value) >= 0) { |
| Function (anonymous_1052) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1053) | |
|---|---|
| ✓ Was called | configure: function(keywords) {··· assert( Array.isArray(keywords) || keywords === true, this.getOptionName() + ' option requires array or true value'); if (keywords === true) { keywords = defaultKeywords; } this._keywords = keywords; }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | Array.isArray(keywords) || keywords === true, |
| ✓ Was returned | Array.isArray(keywords) || keywords === true, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (keywords === true) {··· keywords = defaultKeywords; } |
| ✓ Negative was executed (else) | }··· this._keywords = keywords; |
| Function (anonymous_1054) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpaceAfterKeywords'; }, |
| Function (anonymous_1055) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) { var nextToken = file.getNextToken(token, {includeComments: true}); if (nextToken.type === 'Punctuator' && nextToken.value === ';') { return; } errors.assert.spacesBetween({ token: token, nextToken: nextToken, exactly: 1, message: 'One space required after "' + token.value + '" keyword' }); }); } |
| Function (anonymous_1056) | |
|---|---|
| ✓ Was called | file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) {··· var nextToken = file.getNextToken(token, {includeComments: true}); if (nextToken.type === 'Punctuator' && nextToken.value === ';') { return; } errors.assert.spacesBetween({ token: token, nextToken: nextToken, exactly: 1, message: 'One space required after "' + token.value + '" keyword' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (nextToken.type === 'Punctuator' && nextToken.value === ';') {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.spacesBetween({ |
| Branch LogicalExpression | |
| ✓ Was returned | if (nextToken.type === 'Punctuator' && nextToken.value === ';') { |
| ✓ Was returned | if (nextToken.type === 'Punctuator' && nextToken.value === ';') { |
| Function (anonymous_1057) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1058) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true || options === 'allowSlash' || typeof options === 'object', this.getOptionName() + ' option requires a true value ' + 'or an object with String[] `allExcept` property' ); // verify first item in `allExcept` property in object (if it's an object) assert( typeof options !== 'object' || Array.isArray(options.allExcept) && typeof options.allExcept[0] === 'string', 'Property `allExcept` in ' + this.getOptionName() + ' should be an array of strings' ); // don't check triple slashed comments, microsoft js doc convention. see #593 // exceptions. see #592 // need to drop allowSlash support in 2.0. Fixes #697 this._allExcept = options === 'allowSlash' ? ['/'] : options.allExcept || []; }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | typeof options === 'object', |
| ✓ Was returned | options === true ||··· options === 'allowSlash' || |
| Branch LogicalExpression | |
| ✓ Was returned | options === 'allowSlash' || |
| ✓ Was returned | options === true || |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | Array.isArray(options.allExcept) &&··· typeof options.allExcept[0] === 'string', |
| ✓ Was returned | typeof options !== 'object' || |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | typeof options.allExcept[0] === 'string', |
| ✗ Was not returned | Array.isArray(options.allExcept) && |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | this._allExcept = options === 'allowSlash' ? ['/'] : |
| ✓ Negative was returned (: ...) | options.allExcept || []; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options.allExcept || []; |
| ✓ Was returned | options.allExcept || []; |
| Function (anonymous_1059) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpaceAfterLineComment'; }, |
| Function (anonymous_1060) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var allExcept = this._allExcept; file.iterateTokensByType('Line', function(comment) { var value = comment.value; // cutout exceptions allExcept.forEach(function(el) { if (value.indexOf(el) === 0) { value = value.substr(el.length); } }); if (value.length === 0) { return; } if (value[0] !== ' ') { errors.add('Missing space after line comment', comment.loc.start); } }); } |
| Function (anonymous_1061) | |
|---|---|
| ✓ Was called | file.iterateTokensByType('Line', function(comment) {··· var value = comment.value; // cutout exceptions allExcept.forEach(function(el) { if (value.indexOf(el) === 0) { value = value.substr(el.length); } }); if (value.length === 0) { return; } if (value[0] !== ' ') { errors.add('Missing space after line comment', comment.loc.start); } }); |
| Function (anonymous_1062) | |
|---|---|
| ✓ Was called | allExcept.forEach(function(el) {··· if (value.indexOf(el) === 0) { value = value.substr(el.length); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value.indexOf(el) === 0) {··· value = value.substr(el.length); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value.length === 0) {··· return; } |
| ✓ Negative was executed (else) | }··· if (value[0] !== ' ') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value[0] !== ' ') {··· errors.add('Missing space after line comment', comment.loc.start); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_1063) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1064) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_1065) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpaceAfterObjectKeys'; }, |
| Function (anonymous_1066) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('ObjectExpression', function(node) { node.properties.forEach(function(property) { if (property.shorthand || property.kind !== 'init' || node.type === 'SpreadProperty') { return; } var token = file.getLastNodeToken(property.key); if (property.computed === true) { token = file.getNextToken(token); } errors.assert.whitespaceBetween({ token: token, nextToken: file.getNextToken(token), message: 'Missing space after key' }); }); }); } |
| Function (anonymous_1067) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('ObjectExpression', function(node) {··· node.properties.forEach(function(property) { if (property.shorthand || property.kind !== 'init' || node.type === 'SpreadProperty') { return; } var token = file.getLastNodeToken(property.key); if (property.computed === true) { token = file.getNextToken(token); } errors.assert.whitespaceBetween({ token: token, nextToken: file.getNextToken(token), message: 'Missing space after key' }); }); }); |
| Function (anonymous_1068) | |
|---|---|
| ✓ Was called | node.properties.forEach(function(property) {··· if (property.shorthand || property.kind !== 'init' || node.type === 'SpreadProperty') { return; } var token = file.getLastNodeToken(property.key); if (property.computed === true) { token = file.getNextToken(token); } errors.assert.whitespaceBetween({ token: token, nextToken: file.getNextToken(token), message: 'Missing space after key' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | node.type === 'SpreadProperty') {··· return; } |
| ✓ Negative was executed (else) | }··· var token = file.getLastNodeToken(property.key); |
| Branch LogicalExpression | |
| ✓ Was returned | node.type === 'SpreadProperty') { |
| ✓ Was returned | if (property.shorthand || property.kind !== 'init' || |
| Branch LogicalExpression | |
| ✓ Was returned | if (property.shorthand || property.kind !== 'init' || |
| ✓ Was returned | if (property.shorthand || property.kind !== 'init' || |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (property.computed === true) {··· token = file.getNextToken(token); } |
| ✓ Negative was executed (else) | }··· errors.assert.whitespaceBetween({ |
| Function (anonymous_1069) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1070) | |
|---|---|
| ✓ Was called | configure: function(operators) {··· var isTrue = operators === true; assert( Array.isArray(operators) || isTrue, this.getOptionName() + ' option requires array or true value' ); if (isTrue) { operators = defaultOperators; } this._operatorIndex = {}; for (var i = 0, l = operators.length; i < l; i++) { this._operatorIndex[operators[i]] = true; } }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | Array.isArray(operators) || isTrue, |
| ✓ Was returned | Array.isArray(operators) || isTrue, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isTrue) {··· operators = defaultOperators; } |
| ✓ Negative was executed (else) | }··· this._operatorIndex = {}; |
| Function (anonymous_1071) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpaceAfterPrefixUnaryOperators'; }, |
| Function (anonymous_1072) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var operatorIndex = this._operatorIndex; file.iterateNodesByType(['UnaryExpression', 'UpdateExpression'], function(node) { // Check "node.prefix" for prefix type of (inc|dec)rement if (node.prefix && operatorIndex[node.operator]) { var argument = node.argument.type; var operatorToken = file.getFirstNodeToken(node); var nextToken = file.getNextToken(operatorToken); // Do not report consecutive operators (#405) if ( argument === 'UnaryExpression' || argument === 'UpdateExpression' && nextToken.value !== '(' ) { return; } errors.assert.whitespaceBetween({ token: operatorToken, nextToken: nextToken, message: 'Operator ' + node.operator + ' should not stick to operand' }); } }); } |
| Function (anonymous_1073) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['UnaryExpression', 'UpdateExpression'], function(node) {··· // Check "node.prefix" for prefix type of (inc|dec)rement if (node.prefix && operatorIndex[node.operator]) { var argument = node.argument.type; var operatorToken = file.getFirstNodeToken(node); var nextToken = file.getNextToken(operatorToken); // Do not report consecutive operators (#405) if ( argument === 'UnaryExpression' || argument === 'UpdateExpression' && nextToken.value !== '(' ) { return; } errors.assert.whitespaceBetween({ token: operatorToken, nextToken: nextToken, message: 'Operator ' + node.operator + ' should not stick to operand' }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.prefix && operatorIndex[node.operator]) {··· var argument = node.argument.type; var operatorToken = file.getFirstNodeToken(node); var nextToken = file.getNextToken(operatorToken); // Do not report consecutive operators (#405) if ( argument === 'UnaryExpression' || argument === 'UpdateExpression' && nextToken.value !== '(' ) { return; } errors.assert.whitespaceBetween({ token: operatorToken, nextToken: nextToken, message: 'Operator ' + node.operator + ' should not stick to operand' }); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | if (node.prefix && operatorIndex[node.operator]) { |
| ✗ Was not returned | if (node.prefix && operatorIndex[node.operator]) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | ) {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.whitespaceBetween({ |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | argument === 'UnaryExpression' || argument === 'UpdateExpression' &&··· nextToken.value !== '(' |
| ✓ Was returned | argument === 'UnaryExpression' || argument === 'UpdateExpression' && |
| Branch LogicalExpression | |
| ✓ Was returned | nextToken.value !== '(' |
| ✓ Was returned | argument === 'UnaryExpression' || argument === 'UpdateExpression' && |
| Function (anonymous_1075) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1076) | |
|---|---|
| ✓ Was called | configure: function(operators) {··· var isTrue = operators === true; assert( Array.isArray(operators) || isTrue, this.getOptionName() + ' option requires array or true value' ); if (isTrue) { operators = allOperators; } this._operatorIndex = {}; for (var i = 0, l = operators.length; i < l; i++) { this._operatorIndex[operators[i]] = true; } }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | Array.isArray(operators) || isTrue, |
| ✓ Was returned | Array.isArray(operators) || isTrue, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isTrue) {··· operators = allOperators; } |
| ✓ Negative was executed (else) | }··· this._operatorIndex = {}; |
| Function (anonymous_1077) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpaceBeforeBinaryOperators'; }, |
| Function (anonymous_1078) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var operators = this._operatorIndex; // Comma if (operators[',']) { file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { errors.assert.whitespaceBetween({ token: file.getPrevToken(token), nextToken: token, message: 'Operator , should not stick to preceding expression' }); }); } // For everything else file.iterateNodesByType( ['BinaryExpression', 'AssignmentExpression', 'VariableDeclarator', 'LogicalExpression'], function(node) { var operator; var expression; if (node.type === 'VariableDeclarator') { expression = node.init; operator = '='; } else { operator = node.operator; expression = node.right; } if (expression === null) { return; } var operatorToken = file.findPrevOperatorToken( file.getFirstNodeToken(expression), operator ); var prevToken = file.getPrevToken(operatorToken); if (operators[operator]) { errors.assert.whitespaceBetween({ token: prevToken, nextToken: operatorToken, message: 'Operator ' + operator + ' should not stick to preceding expression' }); } } ); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (operators[',']) {··· file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { errors.assert.whitespaceBetween({ token: file.getPrevToken(token), nextToken: token, message: 'Operator , should not stick to preceding expression' }); }); } |
| ✓ Negative was executed (else) | }··· // For everything else |
| Function (anonymous_1079) | |
|---|---|
| ✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) {··· errors.assert.whitespaceBetween({ token: file.getPrevToken(token), nextToken: token, message: 'Operator , should not stick to preceding expression' }); }); |
| Function (anonymous_1080) | |
|---|---|
| ✓ Was called | function(node) {··· var operator; var expression; if (node.type === 'VariableDeclarator') { expression = node.init; operator = '='; } else { operator = node.operator; expression = node.right; } if (expression === null) { return; } var operatorToken = file.findPrevOperatorToken( file.getFirstNodeToken(expression), operator ); var prevToken = file.getPrevToken(operatorToken); if (operators[operator]) { errors.assert.whitespaceBetween({ token: prevToken, nextToken: operatorToken, message: 'Operator ' + operator + ' should not stick to preceding expression' }); } } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.type === 'VariableDeclarator') {··· expression = node.init; operator = '='; } else { |
| ✓ Negative was executed (else) | } else {··· operator = node.operator; expression = node.right; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (expression === null) {··· return; } |
| ✓ Negative was executed (else) | }··· var operatorToken = file.findPrevOperatorToken( |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (operators[operator]) {··· errors.assert.whitespaceBetween({ token: prevToken, nextToken: operatorToken, message: 'Operator ' + operator + ' should not stick to preceding expression' }); } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_1081) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1082) | |
|---|---|
| ✓ Was called | configure: function(requireSpaceBeforeBlockStatements) {··· assert( typeof requireSpaceBeforeBlockStatements === 'boolean' || typeof requireSpaceBeforeBlockStatements === 'number', this.getOptionName() + ' option requires number or bolean' ); assert( requireSpaceBeforeBlockStatements >= 1, this.getOptionName() + ' option requires true value or a number greater than equal to 1 or should be removed' ); this._count = +requireSpaceBeforeBlockStatements; }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | typeof requireSpaceBeforeBlockStatements === 'number', |
| ✓ Was returned | typeof requireSpaceBeforeBlockStatements === 'boolean' || |
| Function (anonymous_1083) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpaceBeforeBlockStatements'; }, |
| Function (anonymous_1084) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var count = this._count; file.iterateNodesByType('BlockStatement', function(node) { var first = file.getFirstNodeToken(node); errors.assert.spacesBetween({ token: file.getPrevToken(first), nextToken: first, atLeast: count, disallowNewLine: true, message: 'One (or more) spaces required before opening brace for block expressions' }); }); } |
| Function (anonymous_1085) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('BlockStatement', function(node) {··· var first = file.getFirstNodeToken(node); errors.assert.spacesBetween({ token: file.getPrevToken(first), nextToken: first, atLeast: count, disallowNewLine: true, message: 'One (or more) spaces required before opening brace for block expressions' }); }); |
| Function (anonymous_1086) | |
|---|---|
| ✓ Was called | module.exports = function() {··· }; |
| Function (anonymous_1087) | |
|---|---|
| ✓ Was called | configure: function(option) {··· assert( option === true, this.getOptionName() + ' option requires true value' ); }, |
| Function (anonymous_1088) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpaceBeforeComma'; }, |
| Function (anonymous_1089) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { var prevToken = file.getPrevToken(token); errors.assert.whitespaceBetween({ token: prevToken, nextToken: token, message: 'Space required before comma' }); }); } |
| Function (anonymous_1090) | |
|---|---|
| ✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) {··· var prevToken = file.getPrevToken(token); errors.assert.whitespaceBetween({ token: prevToken, nextToken: token, message: 'Space required before comma' }); }); |
| Function (anonymous_1091) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1092) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_1093) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpaceBeforeDestructuredValues'; }, |
| Function (anonymous_1094) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var checkSpaceMissing = function(propKey) { var keyToken = file.getFirstNodeToken(propKey); var colon = file.findNextToken(keyToken, 'Punctuator', ':'); errors.assert.whitespaceBetween({ token: colon, nextToken: file.getNextToken(colon), message: 'Missing space after key colon' }); }; var letsCheckThisOne = function(item) { if (!item) { return; } if (item.type === 'ObjectPattern') { item.properties.forEach(function(property) { if (property.shorthand || property.method || property.kind !== 'init') { return; } checkSpaceMissing(property.key); //Strategy for nested structures var propValue = property.value; if (!propValue) { return; } letsCheckThisOne(propValue); }); } if (item.type === 'ArrayPattern') { item.elements.forEach(letsCheckThisOne); } }; file.iterateNodesByType(['VariableDeclaration', 'AssignmentExpression'], function(node) { if (node.type === 'VariableDeclaration') { node.declarations.forEach(function(declaration) { letsCheckThisOne(declaration.id || {}); }); } if (node.type === 'AssignmentExpression') { var left = node.left; if (left) { letsCheckThisOne(left); } } }); } |
| Function (anonymous_1095) | |
|---|---|
| ✓ Was called | var checkSpaceMissing = function(propKey) {··· var keyToken = file.getFirstNodeToken(propKey); var colon = file.findNextToken(keyToken, 'Punctuator', ':'); errors.assert.whitespaceBetween({ token: colon, nextToken: file.getNextToken(colon), message: 'Missing space after key colon' }); }; |
| Function (anonymous_1096) | |
|---|---|
| ✓ Was called | var letsCheckThisOne = function(item) {··· if (!item) { return; } if (item.type === 'ObjectPattern') { item.properties.forEach(function(property) { if (property.shorthand || property.method || property.kind !== 'init') { return; } checkSpaceMissing(property.key); //Strategy for nested structures var propValue = property.value; if (!propValue) { return; } letsCheckThisOne(propValue); }); } if (item.type === 'ArrayPattern') { item.elements.forEach(letsCheckThisOne); } }; |
| Branch IfStatement | |
|---|---|
| ✗ Positive was not executed (if) | if (!item) {··· return; } |
| ✓ Negative was executed (else) | }··· if (item.type === 'ObjectPattern') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (item.type === 'ObjectPattern') {··· item.properties.forEach(function(property) { if (property.shorthand || property.method || property.kind !== 'init') { return; } checkSpaceMissing(property.key); //Strategy for nested structures var propValue = property.value; if (!propValue) { return; } letsCheckThisOne(propValue); }); } |
| ✓ Negative was executed (else) | }··· if (item.type === 'ArrayPattern') { |
| Function (anonymous_1097) | |
|---|---|
| ✓ Was called | item.properties.forEach(function(property) {··· if (property.shorthand || property.method || property.kind !== 'init') { return; } checkSpaceMissing(property.key); //Strategy for nested structures var propValue = property.value; if (!propValue) { return; } letsCheckThisOne(propValue); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (property.shorthand || property.method || property.kind !== 'init') {··· return; } |
| ✓ Negative was executed (else) | }··· checkSpaceMissing(property.key); |
| Branch LogicalExpression | |
| ✓ Was returned | if (property.shorthand || property.method || property.kind !== 'init') { |
| ✓ Was returned | if (property.shorthand || property.method || property.kind !== 'init') { |
| Branch LogicalExpression | |
| ✓ Was returned | if (property.shorthand || property.method || property.kind !== 'init') { |
| ✓ Was returned | if (property.shorthand || property.method || property.kind !== 'init') { |
| Branch IfStatement | |
|---|---|
| ✗ Positive was not executed (if) | if (!propValue) {··· return; } |
| ✓ Negative was executed (else) | }··· letsCheckThisOne(propValue); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (item.type === 'ArrayPattern') {··· item.elements.forEach(letsCheckThisOne); } |
| ✓ Negative was executed (else) | }··· }; |
| Function (anonymous_1098) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['VariableDeclaration', 'AssignmentExpression'], function(node) {··· if (node.type === 'VariableDeclaration') { node.declarations.forEach(function(declaration) { letsCheckThisOne(declaration.id || {}); }); } if (node.type === 'AssignmentExpression') { var left = node.left; if (left) { letsCheckThisOne(left); } } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.type === 'VariableDeclaration') {··· node.declarations.forEach(function(declaration) { letsCheckThisOne(declaration.id || {}); }); } |
| ✓ Negative was executed (else) | }··· if (node.type === 'AssignmentExpression') { |
| Function (anonymous_1099) | |
|---|---|
| ✓ Was called | node.declarations.forEach(function(declaration) {··· letsCheckThisOne(declaration.id || {}); }); |
| Branch LogicalExpression | |
|---|---|
| ✗ Was not returned | letsCheckThisOne(declaration.id || {}); |
| ✓ Was returned | letsCheckThisOne(declaration.id || {}); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.type === 'AssignmentExpression') {··· var left = node.left; if (left) { letsCheckThisOne(left); } } |
| ✓ Negative was executed (else) | }··· }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (left) {··· letsCheckThisOne(left); } |
| ✗ Negative was not executed (else) | }··· } |
| Function (anonymous_1100) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1101) | |
|---|---|
| ✓ Was called | configure: function(keywords) {··· var isValidObject = (keywords === Object(keywords) && keywords.hasOwnProperty('allExcept')); assert( Array.isArray(keywords) || keywords === true || isValidObject, this.getOptionName() + ' option requires array, object with "allExcept" property or true value'); var excludedKeywords = ignoredKeywords; if (isValidObject) { excludedKeywords = keywords.allExcept; } if (!Array.isArray(keywords)) { keywords = defaultKeywords.filter(function(keyword) { return (excludedKeywords.indexOf(keyword) === -1); }); } this._keywords = keywords; }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | var isValidObject = (keywords === Object(keywords) && keywords.hasOwnProperty('allExcept')); |
| ✓ Was returned | var isValidObject = (keywords === Object(keywords) && keywords.hasOwnProperty('allExcept')); |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | Array.isArray(keywords) || keywords === true || isValidObject, |
| ✓ Was returned | Array.isArray(keywords) || keywords === true || isValidObject, |
| Branch LogicalExpression | |
| ✓ Was returned | Array.isArray(keywords) || keywords === true || isValidObject, |
| ✓ Was returned | Array.isArray(keywords) || keywords === true || isValidObject, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isValidObject) {··· excludedKeywords = keywords.allExcept; } |
| ✓ Negative was executed (else) | }··· if (!Array.isArray(keywords)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!Array.isArray(keywords)) {··· keywords = defaultKeywords.filter(function(keyword) { return (excludedKeywords.indexOf(keyword) === -1); }); } |
| ✓ Negative was executed (else) | }··· this._keywords = keywords; |
| Function (anonymous_1102) | |
|---|---|
| ✓ Was called | keywords = defaultKeywords.filter(function(keyword) {··· return (excludedKeywords.indexOf(keyword) === -1); }); |
| Function (anonymous_1103) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpaceBeforeKeywords'; }, |
| Function (anonymous_1104) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) { var prevToken = file.getPrevToken(token, {includeComments: true}); if (!prevToken || prevToken.isComment) { return; } if (prevToken.type !== 'Punctuator' || prevToken.value !== ';') { errors.assert.whitespaceBetween({ token: prevToken, nextToken: token, message: 'Missing space before "' + token.value + '" keyword' }); } }); } |
| Function (anonymous_1105) | |
|---|---|
| ✓ Was called | file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) {··· var prevToken = file.getPrevToken(token, {includeComments: true}); if (!prevToken || prevToken.isComment) { return; } if (prevToken.type !== 'Punctuator' || prevToken.value !== ';') { errors.assert.whitespaceBetween({ token: prevToken, nextToken: token, message: 'Missing space before "' + token.value + '" keyword' }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!prevToken || prevToken.isComment) {··· return; } |
| ✓ Negative was executed (else) | }··· if (prevToken.type !== 'Punctuator' || prevToken.value !== ';') { |
| Branch LogicalExpression | |
| ✓ Was returned | if (!prevToken || prevToken.isComment) { |
| ✓ Was returned | if (!prevToken || prevToken.isComment) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (prevToken.type !== 'Punctuator' || prevToken.value !== ';') {··· errors.assert.whitespaceBetween({ token: prevToken, nextToken: token, message: 'Missing space before "' + token.value + '" keyword' }); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | if (prevToken.type !== 'Punctuator' || prevToken.value !== ';') { |
| ✗ Was not returned | if (prevToken.type !== 'Punctuator' || prevToken.value !== ';') { |
| Function (anonymous_1106) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1107) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_1108) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpaceBeforeObjectValues'; }, |
| Function (anonymous_1109) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('ObjectExpression', function(node) { node.properties.forEach(function(property) { if (property.shorthand || property.method || property.kind !== 'init' || node.type === 'SpreadProperty') { return; } var keyToken = file.getFirstNodeToken(property.key); var colon = file.findNextToken(keyToken, 'Punctuator', ':'); errors.assert.whitespaceBetween({ token: colon, nextToken: file.getNextToken(colon), message: 'Missing space after key colon' }); }); }); } |
| Function (anonymous_1110) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('ObjectExpression', function(node) {··· node.properties.forEach(function(property) { if (property.shorthand || property.method || property.kind !== 'init' || node.type === 'SpreadProperty') { return; } var keyToken = file.getFirstNodeToken(property.key); var colon = file.findNextToken(keyToken, 'Punctuator', ':'); errors.assert.whitespaceBetween({ token: colon, nextToken: file.getNextToken(colon), message: 'Missing space after key colon' }); }); }); |
| Function (anonymous_1111) | |
|---|---|
| ✓ Was called | node.properties.forEach(function(property) {··· if (property.shorthand || property.method || property.kind !== 'init' || node.type === 'SpreadProperty') { return; } var keyToken = file.getFirstNodeToken(property.key); var colon = file.findNextToken(keyToken, 'Punctuator', ':'); errors.assert.whitespaceBetween({ token: colon, nextToken: file.getNextToken(colon), message: 'Missing space after key colon' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | node.type === 'SpreadProperty') {··· return; } |
| ✓ Negative was executed (else) | }··· var keyToken = file.getFirstNodeToken(property.key); |
| Branch LogicalExpression | |
| ✓ Was returned | node.type === 'SpreadProperty') { |
| ✓ Was returned | if (property.shorthand || property.method || property.kind !== 'init' || |
| Branch LogicalExpression | |
| ✓ Was returned | if (property.shorthand || property.method || property.kind !== 'init' || |
| ✓ Was returned | if (property.shorthand || property.method || property.kind !== 'init' || |
| Branch LogicalExpression | |
| ✓ Was returned | if (property.shorthand || property.method || property.kind !== 'init' || |
| ✓ Was returned | if (property.shorthand || property.method || property.kind !== 'init' || |
| Function (anonymous_1112) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1113) | |
|---|---|
| ✓ Was called | configure: function(operators) {··· var isTrue = operators === true; assert( Array.isArray(operators) || isTrue, this.getOptionName() + ' option requires array or true value' ); if (isTrue) { operators = defaultOperators; } this._operatorIndex = {}; for (var i = 0, l = operators.length; i < l; i++) { this._operatorIndex[operators[i]] = true; } }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | Array.isArray(operators) || isTrue, |
| ✓ Was returned | Array.isArray(operators) || isTrue, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isTrue) {··· operators = defaultOperators; } |
| ✓ Negative was executed (else) | }··· this._operatorIndex = {}; |
| Function (anonymous_1114) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpaceBeforePostfixUnaryOperators'; }, |
| Function (anonymous_1115) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var operatorIndex = this._operatorIndex; // 'UpdateExpression' involve only ++ and -- operators file.iterateNodesByType('UpdateExpression', function(node) { // "!node.prefix" means postfix type of (inc|dec)rement if (!node.prefix && operatorIndex[node.operator]) { var operatorToken = file.getLastNodeToken(node); errors.assert.whitespaceBetween({ token: file.getPrevToken(operatorToken), nextToken: operatorToken, message: 'Operator ' + node.operator + ' should not stick to operand' }); } }); } |
| Function (anonymous_1116) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('UpdateExpression', function(node) {··· // "!node.prefix" means postfix type of (inc|dec)rement if (!node.prefix && operatorIndex[node.operator]) { var operatorToken = file.getLastNodeToken(node); errors.assert.whitespaceBetween({ token: file.getPrevToken(operatorToken), nextToken: operatorToken, message: 'Operator ' + node.operator + ' should not stick to operand' }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!node.prefix && operatorIndex[node.operator]) {··· var operatorToken = file.getLastNodeToken(node); errors.assert.whitespaceBetween({ token: file.getPrevToken(operatorToken), nextToken: operatorToken, message: 'Operator ' + node.operator + ' should not stick to operand' }); } |
| ✗ Negative was not executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | if (!node.prefix && operatorIndex[node.operator]) { |
| ✗ Was not returned | if (!node.prefix && operatorIndex[node.operator]) { |
| Function (anonymous_1117) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1118) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_1119) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpaceBetweenArguments'; }, |
| Function (anonymous_1120) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType(['CallExpression'], function(node) { node.arguments.forEach(function(param) { var punctuatorToken = file.getPrevToken(file.getFirstNodeToken(param)); if (punctuatorToken.value === ',') { errors.assert.whitespaceBetween({ token: punctuatorToken, nextToken: file.getNextToken(punctuatorToken) }); } }); }); } |
| Function (anonymous_1121) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['CallExpression'], function(node) {··· node.arguments.forEach(function(param) { var punctuatorToken = file.getPrevToken(file.getFirstNodeToken(param)); if (punctuatorToken.value === ',') { errors.assert.whitespaceBetween({ token: punctuatorToken, nextToken: file.getNextToken(punctuatorToken) }); } }); }); |
| Function (anonymous_1122) | |
|---|---|
| ✓ Was called | node.arguments.forEach(function(param) {··· var punctuatorToken = file.getPrevToken(file.getFirstNodeToken(param)); if (punctuatorToken.value === ',') { errors.assert.whitespaceBetween({ token: punctuatorToken, nextToken: file.getNextToken(punctuatorToken) }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (punctuatorToken.value === ',') {··· errors.assert.whitespaceBetween({ token: punctuatorToken, nextToken: file.getNextToken(punctuatorToken) }); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_1123) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1124) | |
|---|---|
| ✓ Was called | configure: function(options) {··· this._exceptions = { 'shorthand': false }; assert( typeof options === 'object', this.getOptionName() + ' option must be the object' ); if ('beforeOpeningRoundBrace' in options) { assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } if ('beforeOpeningCurlyBrace' in options) { assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } if ('allExcept' in options) { if (typeof options.allExcept === 'object') { assert( Array.isArray(options.allExcept), this.getOptionName() + ' option requires "allExcept" to be ' + 'an array' ); assert( options.allExcept.length > 0, this.getOptionName() + ' option requires "allExcept" to have ' + 'at least one item or be set to `true`' ); options.allExcept.forEach(function(except) { if (except === 'shorthand') { this._exceptions.shorthand = true; } else { assert(false, this.getOptionName() + ' option requires ' + '"allExcept" to be an array containing "shorthand"'); } }, this); } else { assert( options.allExcept === true, this.getOptionName() + ' option requires a true value or array' ); this._exceptions.shorthand = true; } } assert( options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, this.getOptionName() + ' must have beforeOpeningCurlyBrace ' + ' or beforeOpeningRoundBrace property' ); this._beforeOpeningRoundBrace = Boolean(options.beforeOpeningRoundBrace); this._beforeOpeningCurlyBrace = Boolean(options.beforeOpeningCurlyBrace); }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('beforeOpeningRoundBrace' in options) {··· assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } |
| ✓ Negative was executed (else) | }··· if ('beforeOpeningCurlyBrace' in options) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('beforeOpeningCurlyBrace' in options) {··· assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } |
| ✓ Negative was executed (else) | }··· if ('allExcept' in options) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('allExcept' in options) {··· if (typeof options.allExcept === 'object') { assert( Array.isArray(options.allExcept), this.getOptionName() + ' option requires "allExcept" to be ' + 'an array' ); assert( options.allExcept.length > 0, this.getOptionName() + ' option requires "allExcept" to have ' + 'at least one item or be set to `true`' ); options.allExcept.forEach(function(except) { if (except === 'shorthand') { this._exceptions.shorthand = true; } else { assert(false, this.getOptionName() + ' option requires ' + '"allExcept" to be an array containing "shorthand"'); } }, this); } else { assert( options.allExcept === true, this.getOptionName() + ' option requires a true value or array' ); this._exceptions.shorthand = true; } } |
| ✓ Negative was executed (else) | }··· assert( |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof options.allExcept === 'object') {··· assert( Array.isArray(options.allExcept), this.getOptionName() + ' option requires "allExcept" to be ' + 'an array' ); assert( options.allExcept.length > 0, this.getOptionName() + ' option requires "allExcept" to have ' + 'at least one item or be set to `true`' ); options.allExcept.forEach(function(except) { if (except === 'shorthand') { this._exceptions.shorthand = true; } else { assert(false, this.getOptionName() + ' option requires ' + '"allExcept" to be an array containing "shorthand"'); } }, this); } else { |
| ✓ Negative was executed (else) | } else {··· assert( options.allExcept === true, this.getOptionName() + ' option requires a true value or array' ); this._exceptions.shorthand = true; } |
| Function (anonymous_1125) | |
|---|---|
| ✓ Was called | options.allExcept.forEach(function(except) {··· if (except === 'shorthand') { this._exceptions.shorthand = true; } else { assert(false, this.getOptionName() + ' option requires ' + '"allExcept" to be an array containing "shorthand"'); } }, this); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (except === 'shorthand') {··· this._exceptions.shorthand = true; } else { |
| ✓ Negative was executed (else) | } else {··· assert(false, this.getOptionName() + ' option requires ' + '"allExcept" to be an array containing "shorthand"'); } |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
| ✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
| Function (anonymous_1126) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpacesInAnonymousFunctionExpression'; }, |
| Function (anonymous_1127) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var beforeOpeningRoundBrace = this._beforeOpeningRoundBrace; var beforeOpeningCurlyBrace = this._beforeOpeningCurlyBrace; var exceptions = this._exceptions; file.iterateNodesByType(['FunctionExpression'], function(node) { var functionNode = node; var parent = node.parentNode; // Ignore syntactic sugar for getters and setters. if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { return; } // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { functionNode = parent.key; if (exceptions.shorthand) { return; } } // anonymous function expressions only if (node.id) { return; } if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } }); } |
| Function (anonymous_1128) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['FunctionExpression'], function(node) {··· var functionNode = node; var parent = node.parentNode; // Ignore syntactic sugar for getters and setters. if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { return; } // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { functionNode = parent.key; if (exceptions.shorthand) { return; } } // anonymous function expressions only if (node.id) { return; } if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) {··· return; } |
| ✓ Negative was executed (else) | }··· // shorthand or constructor methods |
| Branch LogicalExpression | |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (parent.method || parent.type === 'MethodDefinition') {··· functionNode = parent.key; if (exceptions.shorthand) { return; } } |
| ✓ Negative was executed (else) | }··· // anonymous function expressions only |
| Branch LogicalExpression | |
| ✓ Was returned | if (parent.method || parent.type === 'MethodDefinition') { |
| ✓ Was returned | if (parent.method || parent.type === 'MethodDefinition') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (exceptions.shorthand) {··· return; } |
| ✓ Negative was executed (else) | }··· } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.id) {··· return; } |
| ✓ Negative was executed (else) | }··· if (beforeOpeningRoundBrace) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (beforeOpeningRoundBrace) {··· var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } |
| ✓ Negative was executed (else) | }··· if (beforeOpeningCurlyBrace) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.async && functionToken.value === 'async') {··· functionToken = file.getNextToken(functionToken); } |
| ✓ Negative was executed (else) | }··· // if generator, set token to be * instead |
| Branch LogicalExpression | |
| ✓ Was returned | if (node.async && functionToken.value === 'async') { |
| ✓ Was returned | if (node.async && functionToken.value === 'async') { |
| Branch IfStatement | |
|---|---|
| ✗ Positive was not executed (if) | if (node.generator && functionToken.value === 'function') {··· functionToken = file.getNextToken(functionToken); } |
| ✓ Negative was executed (else) | }··· errors.assert.whitespaceBetween({ |
| Branch LogicalExpression | |
| ✗ Was not returned | if (node.generator && functionToken.value === 'function') { |
| ✓ Was returned | if (node.generator && functionToken.value === 'function') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (beforeOpeningCurlyBrace) {··· var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_1129) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1130) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_1131) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpacesInCallExpression'; }, |
| Function (anonymous_1132) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('CallExpression', function(node) { var lastCalleeToken = file.getLastNodeToken(node.callee); var roundBraceToken = file.findNextToken(lastCalleeToken, 'Punctuator', '('); errors.assert.whitespaceBetween({ token: file.getPrevToken(roundBraceToken), nextToken: roundBraceToken, message: 'Missing space before opening round brace' }); }); } |
| Function (anonymous_1133) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('CallExpression', function(node) {··· var lastCalleeToken = file.getLastNodeToken(node.callee); var roundBraceToken = file.findNextToken(lastCalleeToken, 'Punctuator', '('); errors.assert.whitespaceBetween({ token: file.getPrevToken(roundBraceToken), nextToken: roundBraceToken, message: 'Missing space before opening round brace' }); }); |
| Function (anonymous_1134) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1135) | |
|---|---|
| ✓ Was called | configure: function(options) {··· var validProperties = [ 'afterTest', 'beforeConsequent', 'afterConsequent', 'beforeAlternate' ]; var optionName = this.getOptionName(); if (options === true) { options = { 'afterTest': true, 'beforeConsequent': true, 'afterConsequent': true, 'beforeAlternate': true }; } assert( typeof options === 'object', optionName + ' option requires a true value or an object' ); var isProperlyConfigured = validProperties.some(function(key) { var isPresent = key in options; if (isPresent) { assert( options[key] === true, optionName + '.' + key + ' property requires true value or should be removed' ); } return isPresent; }); assert( isProperlyConfigured, optionName + ' must have at least 1 of the following properties: ' + validProperties.join(', ') ); validProperties.forEach(function(property) { this['_' + property] = Boolean(options[property]); }.bind(this)); }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (options === true) {··· options = { 'afterTest': true, 'beforeConsequent': true, 'afterConsequent': true, 'beforeAlternate': true }; } |
| ✓ Negative was executed (else) | }··· assert( |
| Function (anonymous_1136) | |
|---|---|
| ✓ Was called | var isProperlyConfigured = validProperties.some(function(key) {··· var isPresent = key in options; if (isPresent) { assert( options[key] === true, optionName + '.' + key + ' property requires true value or should be removed' ); } return isPresent; }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isPresent) {··· assert( options[key] === true, optionName + '.' + key + ' property requires true value or should be removed' ); } |
| ✓ Negative was executed (else) | }··· return isPresent; |
| Function (anonymous_1137) | |
|---|---|
| ✓ Was called | validProperties.forEach(function(property) {··· this['_' + property] = Boolean(options[property]); }.bind(this)); |
| Function (anonymous_1138) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpacesInConditionalExpression'; }, |
| Function (anonymous_1139) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType(['ConditionalExpression'], function(node) { var consequent = node.consequent; var alternate = node.alternate; var consequentToken = file.getFirstNodeToken(consequent); var alternateToken = file.getFirstNodeToken(alternate); var questionMarkToken = file.findPrevOperatorToken(consequentToken, '?'); var colonToken = file.findPrevOperatorToken(alternateToken, ':'); var token; if (this._afterTest) { token = file.getPrevToken(questionMarkToken); errors.assert.whitespaceBetween({ token: token, nextToken: questionMarkToken, message: 'Missing space after test' }); } if (this._beforeConsequent) { token = file.getNextToken(questionMarkToken); errors.assert.whitespaceBetween({ token: questionMarkToken, nextToken: token, message: 'Missing space before consequent' }); } if (this._afterConsequent) { token = file.getPrevToken(colonToken); errors.assert.whitespaceBetween({ token: token, nextToken: colonToken, message: 'Missing space after consequent' }); } if (this._beforeAlternate) { token = file.getNextToken(colonToken); errors.assert.whitespaceBetween({ token: colonToken, nextToken: token, message: 'Missing space before alternate' }); } }.bind(this)); } |
| Function (anonymous_1140) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['ConditionalExpression'], function(node) {··· var consequent = node.consequent; var alternate = node.alternate; var consequentToken = file.getFirstNodeToken(consequent); var alternateToken = file.getFirstNodeToken(alternate); var questionMarkToken = file.findPrevOperatorToken(consequentToken, '?'); var colonToken = file.findPrevOperatorToken(alternateToken, ':'); var token; if (this._afterTest) { token = file.getPrevToken(questionMarkToken); errors.assert.whitespaceBetween({ token: token, nextToken: questionMarkToken, message: 'Missing space after test' }); } if (this._beforeConsequent) { token = file.getNextToken(questionMarkToken); errors.assert.whitespaceBetween({ token: questionMarkToken, nextToken: token, message: 'Missing space before consequent' }); } if (this._afterConsequent) { token = file.getPrevToken(colonToken); errors.assert.whitespaceBetween({ token: token, nextToken: colonToken, message: 'Missing space after consequent' }); } if (this._beforeAlternate) { token = file.getNextToken(colonToken); errors.assert.whitespaceBetween({ token: colonToken, nextToken: token, message: 'Missing space before alternate' }); } }.bind(this)); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._afterTest) {··· token = file.getPrevToken(questionMarkToken); errors.assert.whitespaceBetween({ token: token, nextToken: questionMarkToken, message: 'Missing space after test' }); } |
| ✓ Negative was executed (else) | }··· if (this._beforeConsequent) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._beforeConsequent) {··· token = file.getNextToken(questionMarkToken); errors.assert.whitespaceBetween({ token: questionMarkToken, nextToken: token, message: 'Missing space before consequent' }); } |
| ✓ Negative was executed (else) | }··· if (this._afterConsequent) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._afterConsequent) {··· token = file.getPrevToken(colonToken); errors.assert.whitespaceBetween({ token: token, nextToken: colonToken, message: 'Missing space after consequent' }); } |
| ✓ Negative was executed (else) | }··· if (this._beforeAlternate) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (this._beforeAlternate) {··· token = file.getNextToken(colonToken); errors.assert.whitespaceBetween({ token: colonToken, nextToken: token, message: 'Missing space before alternate' }); } |
| ✓ Negative was executed (else) | }··· }.bind(this)); |
| Function (anonymous_1141) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1142) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_1143) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpacesInForStatement'; }, |
| Function (anonymous_1144) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('ForStatement', function(node) { if (node.test) { var testToken = file.getFirstNodeToken(node.test); var prevToken = file.getPrevToken(testToken); if (prevToken.value === '(' && TokenCategorizer.categorizeOpenParen(prevToken, file) === 'ParenthesizedExpression') { testToken = prevToken; prevToken = file.getPrevToken(prevToken); } errors.assert.spacesBetween({ token: prevToken, nextToken: testToken, exactly: 1, message: 'One space required after semicolon' }); } if (node.update) { var updateToken = file.getFirstNodeToken(node.update); errors.assert.spacesBetween({ token: file.getPrevToken(updateToken), nextToken: updateToken, exactly: 1, message: 'One space required after semicolon' }); } }); } |
| Function (anonymous_1145) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('ForStatement', function(node) {··· if (node.test) { var testToken = file.getFirstNodeToken(node.test); var prevToken = file.getPrevToken(testToken); if (prevToken.value === '(' && TokenCategorizer.categorizeOpenParen(prevToken, file) === 'ParenthesizedExpression') { testToken = prevToken; prevToken = file.getPrevToken(prevToken); } errors.assert.spacesBetween({ token: prevToken, nextToken: testToken, exactly: 1, message: 'One space required after semicolon' }); } if (node.update) { var updateToken = file.getFirstNodeToken(node.update); errors.assert.spacesBetween({ token: file.getPrevToken(updateToken), nextToken: updateToken, exactly: 1, message: 'One space required after semicolon' }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.test) {··· var testToken = file.getFirstNodeToken(node.test); var prevToken = file.getPrevToken(testToken); if (prevToken.value === '(' && TokenCategorizer.categorizeOpenParen(prevToken, file) === 'ParenthesizedExpression') { testToken = prevToken; prevToken = file.getPrevToken(prevToken); } errors.assert.spacesBetween({ token: prevToken, nextToken: testToken, exactly: 1, message: 'One space required after semicolon' }); } |
| ✓ Negative was executed (else) | }··· if (node.update) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | TokenCategorizer.categorizeOpenParen(prevToken, file) === 'ParenthesizedExpression') {··· testToken = prevToken; prevToken = file.getPrevToken(prevToken); } |
| ✓ Negative was executed (else) | }··· errors.assert.spacesBetween({ |
| Branch LogicalExpression | |
| ✓ Was returned | TokenCategorizer.categorizeOpenParen(prevToken, file) === 'ParenthesizedExpression') { |
| ✓ Was returned | if (prevToken.value === '(' && |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.update) {··· var updateToken = file.getFirstNodeToken(node.update); errors.assert.spacesBetween({ token: file.getPrevToken(updateToken), nextToken: updateToken, exactly: 1, message: 'One space required after semicolon' }); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_1146) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1147) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( typeof options === 'object', this.getOptionName() + ' option must be the object' ); if ('beforeOpeningRoundBrace' in options) { assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } if ('beforeOpeningCurlyBrace' in options) { assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } assert( options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, this.getOptionName() + ' must have beforeOpeningCurlyBrace or beforeOpeningRoundBrace property' ); this._beforeOpeningRoundBrace = Boolean(options.beforeOpeningRoundBrace); this._beforeOpeningCurlyBrace = Boolean(options.beforeOpeningCurlyBrace); }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('beforeOpeningRoundBrace' in options) {··· assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } |
| ✓ Negative was executed (else) | }··· if ('beforeOpeningCurlyBrace' in options) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('beforeOpeningCurlyBrace' in options) {··· assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } |
| ✓ Negative was executed (else) | }··· assert( |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
| ✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
| Function (anonymous_1148) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpacesInFunctionDeclaration'; }, |
| Function (anonymous_1149) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var beforeOpeningRoundBrace = this._beforeOpeningRoundBrace; var beforeOpeningCurlyBrace = this._beforeOpeningCurlyBrace; file.iterateNodesByType(['FunctionDeclaration'], function(node) { // Exception for `export default function` #1376 if (!node.id) { return; } if (beforeOpeningRoundBrace) { // for a named function, use node.id var functionToken = file.getFirstNodeToken(node.id || node); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } }); } |
| Function (anonymous_1150) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['FunctionDeclaration'], function(node) {··· // Exception for `export default function` #1376 if (!node.id) { return; } if (beforeOpeningRoundBrace) { // for a named function, use node.id var functionToken = file.getFirstNodeToken(node.id || node); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!node.id) {··· return; } |
| ✓ Negative was executed (else) | }··· if (beforeOpeningRoundBrace) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (beforeOpeningRoundBrace) {··· // for a named function, use node.id var functionToken = file.getFirstNodeToken(node.id || node); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } |
| ✓ Negative was executed (else) | }··· if (beforeOpeningCurlyBrace) { |
| Branch LogicalExpression | |
|---|---|
| ✗ Was not returned | var functionToken = file.getFirstNodeToken(node.id || node); |
| ✓ Was returned | var functionToken = file.getFirstNodeToken(node.id || node); |
| Branch IfStatement | |
|---|---|
| ✗ Positive was not executed (if) | if (node.async && functionToken.value === 'async') {··· functionToken = file.getNextToken(functionToken); } |
| ✓ Negative was executed (else) | }··· // if generator, set token to be * instead |
| Branch LogicalExpression | |
| ✓ Was returned | if (node.async && functionToken.value === 'async') { |
| ✓ Was returned | if (node.async && functionToken.value === 'async') { |
| Branch IfStatement | |
|---|---|
| ✗ Positive was not executed (if) | if (node.generator && functionToken.value === 'function') {··· functionToken = file.getNextToken(functionToken); } |
| ✓ Negative was executed (else) | }··· errors.assert.whitespaceBetween({ |
| Branch LogicalExpression | |
| ✗ Was not returned | if (node.generator && functionToken.value === 'function') { |
| ✓ Was returned | if (node.generator && functionToken.value === 'function') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (beforeOpeningCurlyBrace) {··· var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_1151) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1152) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( typeof options === 'object', this.getOptionName() + ' option must be the object' ); if ('beforeOpeningRoundBrace' in options) { assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } if ('beforeOpeningCurlyBrace' in options) { assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } assert( options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, this.getOptionName() + ' must have beforeOpeningCurlyBrace or beforeOpeningRoundBrace property' ); this._beforeOpeningRoundBrace = Boolean(options.beforeOpeningRoundBrace); this._beforeOpeningCurlyBrace = Boolean(options.beforeOpeningCurlyBrace); }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('beforeOpeningRoundBrace' in options) {··· assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } |
| ✓ Negative was executed (else) | }··· if ('beforeOpeningCurlyBrace' in options) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('beforeOpeningCurlyBrace' in options) {··· assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } |
| ✓ Negative was executed (else) | }··· assert( |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
| ✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
| Function (anonymous_1153) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpacesInFunctionExpression'; }, |
| Function (anonymous_1154) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var beforeOpeningRoundBrace = this._beforeOpeningRoundBrace; var beforeOpeningCurlyBrace = this._beforeOpeningCurlyBrace; file.iterateNodesByType('FunctionExpression', function(node) { // for a named function, use node.id var functionNode = node.id || node; var parent = node.parentNode; // Ignore syntactic sugar for getters and setters. if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { return; } // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { functionNode = parent.key; } if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } }); } |
| Function (anonymous_1155) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('FunctionExpression', function(node) {··· // for a named function, use node.id var functionNode = node.id || node; var parent = node.parentNode; // Ignore syntactic sugar for getters and setters. if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { return; } // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { functionNode = parent.key; } if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } }); |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | var functionNode = node.id || node; |
| ✓ Was returned | var functionNode = node.id || node; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) {··· return; } |
| ✓ Negative was executed (else) | }··· // shorthand or constructor methods |
| Branch LogicalExpression | |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (parent.method || parent.type === 'MethodDefinition') {··· functionNode = parent.key; } |
| ✓ Negative was executed (else) | }··· if (beforeOpeningRoundBrace) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (parent.method || parent.type === 'MethodDefinition') { |
| ✓ Was returned | if (parent.method || parent.type === 'MethodDefinition') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (beforeOpeningRoundBrace) {··· var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } |
| ✓ Negative was executed (else) | }··· if (beforeOpeningCurlyBrace) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.async && functionToken.value === 'async') {··· functionToken = file.getNextToken(functionToken); } |
| ✓ Negative was executed (else) | }··· // if generator, set token to be * instead |
| Branch LogicalExpression | |
| ✓ Was returned | if (node.async && functionToken.value === 'async') { |
| ✓ Was returned | if (node.async && functionToken.value === 'async') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.generator && functionToken.value === 'function') {··· functionToken = file.getNextToken(functionToken); } |
| ✓ Negative was executed (else) | }··· errors.assert.whitespaceBetween({ |
| Branch LogicalExpression | |
| ✓ Was returned | if (node.generator && functionToken.value === 'function') { |
| ✓ Was returned | if (node.generator && functionToken.value === 'function') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (beforeOpeningCurlyBrace) {··· var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_1156) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1157) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( typeof options === 'object', this.getOptionName() + ' option must be the object' ); if ('beforeOpeningRoundBrace' in options) { assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } if ('beforeOpeningCurlyBrace' in options) { assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } assert( options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, this.getOptionName() + ' must have beforeOpeningCurlyBrace or beforeOpeningRoundBrace property' ); this._beforeOpeningRoundBrace = Boolean(options.beforeOpeningRoundBrace); this._beforeOpeningCurlyBrace = Boolean(options.beforeOpeningCurlyBrace); }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('beforeOpeningRoundBrace' in options) {··· assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } |
| ✓ Negative was executed (else) | }··· if ('beforeOpeningCurlyBrace' in options) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('beforeOpeningCurlyBrace' in options) {··· assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } |
| ✓ Negative was executed (else) | }··· assert( |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
| ✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
| Function (anonymous_1158) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpacesInFunction'; }, |
| Function (anonymous_1159) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var beforeOpeningRoundBrace = this._beforeOpeningRoundBrace; var beforeOpeningCurlyBrace = this._beforeOpeningCurlyBrace; file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) { // for a named function, use node.id var functionNode = node.id || node; var parent = node.parentNode; // Ignore syntactic sugar for getters and setters. if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { return; } // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { functionNode = parent.key; } if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } }); } |
| Function (anonymous_1160) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) {··· // for a named function, use node.id var functionNode = node.id || node; var parent = node.parentNode; // Ignore syntactic sugar for getters and setters. if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { return; } // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { functionNode = parent.key; } if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } }); |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | var functionNode = node.id || node; |
| ✓ Was returned | var functionNode = node.id || node; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) {··· return; } |
| ✓ Negative was executed (else) | }··· // shorthand or constructor methods |
| Branch LogicalExpression | |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (parent.method || parent.type === 'MethodDefinition') {··· functionNode = parent.key; } |
| ✓ Negative was executed (else) | }··· if (beforeOpeningRoundBrace) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (parent.method || parent.type === 'MethodDefinition') { |
| ✓ Was returned | if (parent.method || parent.type === 'MethodDefinition') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (beforeOpeningRoundBrace) {··· var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } |
| ✓ Negative was executed (else) | }··· if (beforeOpeningCurlyBrace) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.async && functionToken.value === 'async') {··· functionToken = file.getNextToken(functionToken); } |
| ✓ Negative was executed (else) | }··· // if generator, set token to be * instead |
| Branch LogicalExpression | |
| ✓ Was returned | if (node.async && functionToken.value === 'async') { |
| ✓ Was returned | if (node.async && functionToken.value === 'async') { |
| Branch IfStatement | |
|---|---|
| ✗ Positive was not executed (if) | if (node.generator && functionToken.value === 'function') {··· functionToken = file.getNextToken(functionToken); } |
| ✓ Negative was executed (else) | }··· errors.assert.whitespaceBetween({ |
| Branch LogicalExpression | |
| ✗ Was not returned | if (node.generator && functionToken.value === 'function') { |
| ✓ Was returned | if (node.generator && functionToken.value === 'function') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (beforeOpeningCurlyBrace) {··· var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_1161) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1162) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( typeof options === 'object', this.getOptionName() + ' option must be an object' ); if ('beforeStar' in options) { assert( options.beforeStar === true, this.getOptionName() + '.beforeStar ' + 'property requires true value or should be removed' ); } if ('afterStar' in options) { assert( options.afterStar === true, this.getOptionName() + '.afterStar ' + 'property requires true value or should be removed' ); } assert( options.beforeStar || options.afterStar, this.getOptionName() + ' must have beforeStar or afterStar property' ); this._beforeStar = options.beforeStar; this._afterStar = options.afterStar; }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('beforeStar' in options) {··· assert( options.beforeStar === true, this.getOptionName() + '.beforeStar ' + 'property requires true value or should be removed' ); } |
| ✗ Negative was not executed (else) | }··· if ('afterStar' in options) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('afterStar' in options) {··· assert( options.afterStar === true, this.getOptionName() + '.afterStar ' + 'property requires true value or should be removed' ); } |
| ✗ Negative was not executed (else) | }··· assert( |
| Branch LogicalExpression | |
|---|---|
| ✗ Was not returned | options.beforeStar || options.afterStar, |
| ✓ Was returned | options.beforeStar || options.afterStar, |
| Function (anonymous_1163) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpacesInGenerator'; }, |
| Function (anonymous_1164) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var beforeStar = this._beforeStar; var afterStar = this._afterStar; file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) { if (!node.generator) { return; } var parent = node.parentNode; var shorthand = false; // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { shorthand = true; node = parent.key; } var currentToken = file.getFirstNodeToken(node); if (node.async && currentToken.value === 'async') { currentToken = file.getNextToken(currentToken); } if (beforeStar && !shorthand) { // currentToken assigned outside of function errors.assert.whitespaceBetween({ token: currentToken, nextToken: file.getNextToken(currentToken), message: 'Missing space before star' }); } if (afterStar) { if (shorthand) { currentToken = file.getPrevToken(currentToken); } else { // currentToken reassigned for star token currentToken = file.getNextToken(currentToken); } errors.assert.whitespaceBetween({ token: currentToken, nextToken: file.getNextToken(currentToken), message: 'Missing space after star' }); } }); } |
| Function (anonymous_1165) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) {··· if (!node.generator) { return; } var parent = node.parentNode; var shorthand = false; // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { shorthand = true; node = parent.key; } var currentToken = file.getFirstNodeToken(node); if (node.async && currentToken.value === 'async') { currentToken = file.getNextToken(currentToken); } if (beforeStar && !shorthand) { // currentToken assigned outside of function errors.assert.whitespaceBetween({ token: currentToken, nextToken: file.getNextToken(currentToken), message: 'Missing space before star' }); } if (afterStar) { if (shorthand) { currentToken = file.getPrevToken(currentToken); } else { // currentToken reassigned for star token currentToken = file.getNextToken(currentToken); } errors.assert.whitespaceBetween({ token: currentToken, nextToken: file.getNextToken(currentToken), message: 'Missing space after star' }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!node.generator) {··· return; } |
| ✓ Negative was executed (else) | }··· var parent = node.parentNode; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (parent.method || parent.type === 'MethodDefinition') {··· shorthand = true; node = parent.key; } |
| ✓ Negative was executed (else) | }··· var currentToken = file.getFirstNodeToken(node); |
| Branch LogicalExpression | |
| ✓ Was returned | if (parent.method || parent.type === 'MethodDefinition') { |
| ✓ Was returned | if (parent.method || parent.type === 'MethodDefinition') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.async && currentToken.value === 'async') {··· currentToken = file.getNextToken(currentToken); } |
| ✓ Negative was executed (else) | }··· if (beforeStar && !shorthand) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (node.async && currentToken.value === 'async') { |
| ✓ Was returned | if (node.async && currentToken.value === 'async') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (beforeStar && !shorthand) {··· // currentToken assigned outside of function errors.assert.whitespaceBetween({ token: currentToken, nextToken: file.getNextToken(currentToken), message: 'Missing space before star' }); } |
| ✓ Negative was executed (else) | }··· if (afterStar) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (beforeStar && !shorthand) { |
| ✗ Was not returned | if (beforeStar && !shorthand) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (afterStar) {··· if (shorthand) { currentToken = file.getPrevToken(currentToken); } else { // currentToken reassigned for star token currentToken = file.getNextToken(currentToken); } errors.assert.whitespaceBetween({ token: currentToken, nextToken: file.getNextToken(currentToken), message: 'Missing space after star' }); } |
| ✗ Negative was not executed (else) | }··· }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (shorthand) {··· currentToken = file.getPrevToken(currentToken); } else { |
| ✓ Negative was executed (else) | } else {··· // currentToken reassigned for star token currentToken = file.getNextToken(currentToken); } |
| Function (anonymous_1166) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1167) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( typeof options === 'object', this.getOptionName() + ' option must be the object' ); if ('beforeOpeningRoundBrace' in options) { assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } if ('beforeOpeningCurlyBrace' in options) { assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } assert( options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, this.getOptionName() + ' must have beforeOpeningCurlyBrace ' + 'or beforeOpeningRoundBrace property' ); this._beforeOpeningRoundBrace = Boolean(options.beforeOpeningRoundBrace); this._beforeOpeningCurlyBrace = Boolean(options.beforeOpeningCurlyBrace); }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('beforeOpeningRoundBrace' in options) {··· assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } |
| ✓ Negative was executed (else) | }··· if ('beforeOpeningCurlyBrace' in options) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('beforeOpeningCurlyBrace' in options) {··· assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } |
| ✓ Negative was executed (else) | }··· assert( |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
| ✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
| Function (anonymous_1168) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpacesInNamedFunctionExpression'; }, |
| Function (anonymous_1169) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var beforeOpeningRoundBrace = this._beforeOpeningRoundBrace; var beforeOpeningCurlyBrace = this._beforeOpeningCurlyBrace; file.iterateNodesByType(['FunctionExpression'], function(node) { var functionNode = node.id; var parent = node.parentNode; // Ignore syntactic sugar for getters and setters. if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { return; } // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { functionNode = parent.key; } // named function expressions only if (node.id) { if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } } }); } |
| Function (anonymous_1170) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['FunctionExpression'], function(node) {··· var functionNode = node.id; var parent = node.parentNode; // Ignore syntactic sugar for getters and setters. if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { return; } // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { functionNode = parent.key; } // named function expressions only if (node.id) { if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) {··· return; } |
| ✓ Negative was executed (else) | }··· // shorthand or constructor methods |
| Branch LogicalExpression | |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| ✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (parent.method || parent.type === 'MethodDefinition') {··· functionNode = parent.key; } |
| ✓ Negative was executed (else) | }··· // named function expressions only |
| Branch LogicalExpression | |
| ✓ Was returned | if (parent.method || parent.type === 'MethodDefinition') { |
| ✓ Was returned | if (parent.method || parent.type === 'MethodDefinition') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.id) {··· if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } } |
| ✓ Negative was executed (else) | }··· }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (beforeOpeningRoundBrace) {··· var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } |
| ✓ Negative was executed (else) | }··· if (beforeOpeningCurlyBrace) { |
| Branch IfStatement | |
|---|---|
| ✗ Positive was not executed (if) | if (node.async && functionToken.value === 'async') {··· functionToken = file.getNextToken(functionToken); } |
| ✓ Negative was executed (else) | }··· errors.assert.whitespaceBetween({ |
| Branch LogicalExpression | |
| ✓ Was returned | if (node.async && functionToken.value === 'async') { |
| ✓ Was returned | if (node.async && functionToken.value === 'async') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (beforeOpeningCurlyBrace) {··· var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_1171) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1172) | |
|---|---|
| ✓ Was called | configure: function(value) {··· var mode; var modes = { 'all': true, 'allButNested': true }; var isObject = typeof value === 'object'; var error = this.getOptionName() + ' rule' + ' requires string value "all" or "allButNested" or object'; if (typeof value === 'string') { assert(modes[value], error); } else if (isObject) { assert('allExcept' in value, error); } else { assert(false, error); } this._exceptions = {}; if (isObject) { (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } else { mode = value; } if (mode === 'allButNested') { this._exceptions['['] = this._exceptions[']'] = true; } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof value === 'string') {··· assert(modes[value], error); } else if (isObject) { |
| ✓ Negative was executed (else) | } else if (isObject) {··· assert('allExcept' in value, error); } else { assert(false, error); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (isObject) {··· assert('allExcept' in value, error); } else { |
| ✓ Negative was executed (else) | } else {··· assert(false, error); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isObject) {··· (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } else { |
| ✓ Negative was executed (else) | } else {··· mode = value; } |
| Function (anonymous_1173) | |
|---|---|
| ✓ Was called | (value.allExcept || []).forEach(function(value) {··· this._exceptions[value] = true; }, this); |
| Branch LogicalExpression | |
| ✗ Was not returned | (value.allExcept || []).forEach(function(value) { |
| ✓ Was returned | (value.allExcept || []).forEach(function(value) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (mode === 'allButNested') {··· this._exceptions['['] = this._exceptions[']'] = true; } |
| ✓ Negative was executed (else) | }··· }, |
| Function (anonymous_1174) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpacesInsideArrayBrackets'; }, |
| Function (anonymous_1175) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var exceptions = this._exceptions; file.iterateNodesByType('ArrayExpression', function(node) { var openBracket = file.getFirstNodeToken(node); var afterOpen = file.getNextToken(openBracket, {includeComments: true}); var closeBracket = file.getLastNodeToken(node); var beforeClose = file.getPrevToken(closeBracket, {includeComments: true}); // Skip for empty array brackets if (afterOpen.value === ']') { return; } if (!(afterOpen.value in exceptions)) { errors.assert.spacesBetween({ token: openBracket, nextToken: afterOpen, exactly: 1, message: 'One space required after opening bracket' }); } if (!(beforeClose.value in exceptions)) { errors.assert.spacesBetween({ token: beforeClose, nextToken: closeBracket, exactly: 1, message: 'One space required before closing bracket' }); } }); } |
| Function (anonymous_1176) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('ArrayExpression', function(node) {··· var openBracket = file.getFirstNodeToken(node); var afterOpen = file.getNextToken(openBracket, {includeComments: true}); var closeBracket = file.getLastNodeToken(node); var beforeClose = file.getPrevToken(closeBracket, {includeComments: true}); // Skip for empty array brackets if (afterOpen.value === ']') { return; } if (!(afterOpen.value in exceptions)) { errors.assert.spacesBetween({ token: openBracket, nextToken: afterOpen, exactly: 1, message: 'One space required after opening bracket' }); } if (!(beforeClose.value in exceptions)) { errors.assert.spacesBetween({ token: beforeClose, nextToken: closeBracket, exactly: 1, message: 'One space required before closing bracket' }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (afterOpen.value === ']') {··· return; } |
| ✓ Negative was executed (else) | }··· if (!(afterOpen.value in exceptions)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!(afterOpen.value in exceptions)) {··· errors.assert.spacesBetween({ token: openBracket, nextToken: afterOpen, exactly: 1, message: 'One space required after opening bracket' }); } |
| ✓ Negative was executed (else) | }··· if (!(beforeClose.value in exceptions)) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!(beforeClose.value in exceptions)) {··· errors.assert.spacesBetween({ token: beforeClose, nextToken: closeBracket, exactly: 1, message: 'One space required before closing bracket' }); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_1177) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1178) | |
|---|---|
| ✓ Was called | configure: function(value) {··· var isObject = typeof value === 'object'; var error = this.getOptionName() + ' rule requires string value true or object'; if (isObject) { assert('allExcept' in value, error); } else { assert(value === true, error); } this._exceptions = {}; if (isObject) { (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isObject) {··· assert('allExcept' in value, error); } else { |
| ✓ Negative was executed (else) | } else {··· assert(value === true, error); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isObject) {··· (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } |
| ✓ Negative was executed (else) | }··· }, |
| Function (anonymous_1179) | |
|---|---|
| ✓ Was called | (value.allExcept || []).forEach(function(value) {··· this._exceptions[value] = true; }, this); |
| Branch LogicalExpression | |
| ✗ Was not returned | (value.allExcept || []).forEach(function(value) { |
| ✓ Was returned | (value.allExcept || []).forEach(function(value) { |
| Function (anonymous_1180) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpacesInsideBrackets'; }, |
| Function (anonymous_1181) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var exceptions = this._exceptions; file.iterateTokenByValue('[', function(token) { var nextToken = file.getNextToken(token, { includeComments: true }); var value = nextToken.value; if (value in exceptions) { return; } // Skip for empty array brackets if (value === ']') { return; } errors.assert.spacesBetween({ token: token, nextToken: nextToken, exactly: 1, message: 'One space required after opening bracket' }); }); file.iterateTokenByValue(']', function(token) { var prevToken = file.getPrevToken(token, { includeComments: true }); var value = prevToken.value; if (value in exceptions) { return; } // Skip for empty array brackets if (value === '[') { return; } errors.assert.spacesBetween({ token: prevToken, nextToken: token, exactly: 1, message: 'One space required before closing bracket' }); }); } |
| Function (anonymous_1182) | |
|---|---|
| ✓ Was called | file.iterateTokenByValue('[', function(token) {··· var nextToken = file.getNextToken(token, { includeComments: true }); var value = nextToken.value; if (value in exceptions) { return; } // Skip for empty array brackets if (value === ']') { return; } errors.assert.spacesBetween({ token: token, nextToken: nextToken, exactly: 1, message: 'One space required after opening bracket' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value in exceptions) {··· return; } |
| ✓ Negative was executed (else) | }··· // Skip for empty array brackets |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value === ']') {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.spacesBetween({ |
| Function (anonymous_1183) | |
|---|---|
| ✓ Was called | file.iterateTokenByValue(']', function(token) {··· var prevToken = file.getPrevToken(token, { includeComments: true }); var value = prevToken.value; if (value in exceptions) { return; } // Skip for empty array brackets if (value === '[') { return; } errors.assert.spacesBetween({ token: prevToken, nextToken: token, exactly: 1, message: 'One space required before closing bracket' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value in exceptions) {··· return; } |
| ✓ Negative was executed (else) | }··· // Skip for empty array brackets |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value === '[') {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.spacesBetween({ |
| Function (anonymous_1184) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1185) | |
|---|---|
| ✓ Was called | configure: function(value) {··· var mode; var modes = { 'all': true, 'allButNested': true }; var isObject = typeof value === 'object'; var error = this.getOptionName() + ' rule' + ' requires string value \'all\' or \'allButNested\' or object'; if (typeof value === 'string') { assert(modes[value], error); } else if (isObject) { assert('allExcept' in value, error); } else { assert(false, error); } this._exceptions = {}; if (isObject) { (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } else { mode = value; } if (mode === 'allButNested') { this._exceptions['}'] = true; } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof value === 'string') {··· assert(modes[value], error); } else if (isObject) { |
| ✓ Negative was executed (else) | } else if (isObject) {··· assert('allExcept' in value, error); } else { assert(false, error); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (isObject) {··· assert('allExcept' in value, error); } else { |
| ✓ Negative was executed (else) | } else {··· assert(false, error); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isObject) {··· (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } else { |
| ✓ Negative was executed (else) | } else {··· mode = value; } |
| Function (anonymous_1186) | |
|---|---|
| ✓ Was called | (value.allExcept || []).forEach(function(value) {··· this._exceptions[value] = true; }, this); |
| Branch LogicalExpression | |
| ✗ Was not returned | (value.allExcept || []).forEach(function(value) { |
| ✓ Was returned | (value.allExcept || []).forEach(function(value) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (mode === 'allButNested') {··· this._exceptions['}'] = true; } |
| ✓ Negative was executed (else) | }··· }, |
| Function (anonymous_1187) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpacesInsideObjectBrackets'; }, |
| Function (anonymous_1188) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var exceptions = this._exceptions; file.iterateNodesByType(['ObjectExpression', 'ObjectPattern'], function(node) { var openingBracket = file.getFirstNodeToken(node); var nextToken = file.getNextToken(openingBracket); // Don't check empty object if (nextToken.value === '}') { return; } errors.assert.spacesBetween({ token: openingBracket, nextToken: nextToken, exactly: 1, message: 'One space required after opening curly brace' }); var closingBracket = file.getLastNodeToken(node); var prevToken = file.getPrevToken(closingBracket); if (prevToken.value in exceptions) { return; } errors.assert.spacesBetween({ token: prevToken, nextToken: closingBracket, exactly: 1, message: 'One space required before closing curly brace' }); }); } |
| Function (anonymous_1189) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['ObjectExpression', 'ObjectPattern'], function(node) {··· var openingBracket = file.getFirstNodeToken(node); var nextToken = file.getNextToken(openingBracket); // Don't check empty object if (nextToken.value === '}') { return; } errors.assert.spacesBetween({ token: openingBracket, nextToken: nextToken, exactly: 1, message: 'One space required after opening curly brace' }); var closingBracket = file.getLastNodeToken(node); var prevToken = file.getPrevToken(closingBracket); if (prevToken.value in exceptions) { return; } errors.assert.spacesBetween({ token: prevToken, nextToken: closingBracket, exactly: 1, message: 'One space required before closing curly brace' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (nextToken.value === '}') {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.spacesBetween({ |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (prevToken.value in exceptions) {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.spacesBetween({ |
| Function (anonymous_1190) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1191) | |
|---|---|
| ✓ Was called | configure: function(value) {··· var mode; var modes = { 'all': true, 'allButNested': true }; var isObject = typeof value === 'object'; var error = this.getOptionName() + ' rule' + ' requires string value \'all\' or \'allButNested\' or object'; if (typeof value === 'string') { assert(modes[value], error); } else if (isObject) { assert( 'all' in value || 'allButNested' in value, error ); } else { assert(false, error); } this._exceptions = {}; this._exceptSingleQuote = false; this._exceptDoubleQuote = false; this._ignoreParenthesizedExpression = false; if (isObject) { mode = 'all' in value ? 'all' : 'allButNested'; (value.except || []).forEach(function(value) { if (value === '\'') { this._exceptSingleQuote = true; } if (value === '"') { this._exceptDoubleQuote = true; } this._exceptions[value] = true; }, this); if (value.ignoreParenthesizedExpression === true) { this._ignoreParenthesizedExpression = true; } } else { mode = value; } if (mode === 'allButNested') { this._exceptions[')'] = this._exceptions['('] = true; } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof value === 'string') {··· assert(modes[value], error); } else if (isObject) { |
| ✓ Negative was executed (else) | } else if (isObject) {··· assert( 'all' in value || 'allButNested' in value, error ); } else { assert(false, error); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (isObject) {··· assert( 'all' in value || 'allButNested' in value, error ); } else { |
| ✓ Negative was executed (else) | } else {··· assert(false, error); } |
| Branch LogicalExpression | |
|---|---|
| ✗ Was not returned | 'all' in value || 'allButNested' in value, |
| ✓ Was returned | 'all' in value || 'allButNested' in value, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isObject) {··· mode = 'all' in value ? 'all' : 'allButNested'; (value.except || []).forEach(function(value) { if (value === '\'') { this._exceptSingleQuote = true; } if (value === '"') { this._exceptDoubleQuote = true; } this._exceptions[value] = true; }, this); if (value.ignoreParenthesizedExpression === true) { this._ignoreParenthesizedExpression = true; } } else { |
| ✓ Negative was executed (else) | } else {··· mode = value; } |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | mode = 'all' in value ? 'all' : 'allButNested'; |
| ✗ Negative was not returned (: ...) | mode = 'all' in value ? 'all' : 'allButNested'; |
| Function (anonymous_1192) | |
|---|---|
| ✓ Was called | (value.except || []).forEach(function(value) {··· if (value === '\'') { this._exceptSingleQuote = true; } if (value === '"') { this._exceptDoubleQuote = true; } this._exceptions[value] = true; }, this); |
| Branch LogicalExpression | |
| ✓ Was returned | (value.except || []).forEach(function(value) { |
| ✓ Was returned | (value.except || []).forEach(function(value) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value === '\'') {··· this._exceptSingleQuote = true; } |
| ✓ Negative was executed (else) | }··· if (value === '"') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value === '"') {··· this._exceptDoubleQuote = true; } |
| ✓ Negative was executed (else) | }··· this._exceptions[value] = true; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value.ignoreParenthesizedExpression === true) {··· this._ignoreParenthesizedExpression = true; } |
| ✓ Negative was executed (else) | }··· } else { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (mode === 'allButNested') {··· this._exceptions[')'] = this._exceptions['('] = true; } |
| ✓ Negative was executed (else) | }··· }, |
| Function (anonymous_1193) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpacesInsideParentheses'; }, |
| Function (anonymous_1194) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var exceptions = this._exceptions; var singleQuote = this._exceptSingleQuote; var doubleQuote = this._exceptDoubleQuote; var ignoreParenthesizedExpression = this._ignoreParenthesizedExpression; file.iterateTokenByValue('(', function(token) { var nextToken = file.getNextToken(token, {includeComments: true}); var value = nextToken.value; if ( ignoreParenthesizedExpression && TokenCategorizer.categorizeOpenParen(token, file) === 'ParenthesizedExpression' ) { return; } if (value in exceptions) { return; } if (doubleQuote && nextToken.type === 'String' && value[0] === '"') { return; } if (singleQuote && nextToken.type === 'String' && value[0] === '\'') { return; } // Skip for empty parentheses if (value === ')') { return; } errors.assert.whitespaceBetween({ token: token, nextToken: nextToken, message: 'Missing space after opening round bracket' }); }); file.iterateTokenByValue(')', function(token) { var prevToken = file.getPrevToken(token, {includeComments: true}); var value = prevToken.value; if ( ignoreParenthesizedExpression && TokenCategorizer.categorizeCloseParen(token, file) === 'ParenthesizedExpression' ) { return; } if (value in exceptions) { // Special case - foo( object[i] ) if (!( value === ']' && file.getNodeByRange(token.range[0] - 1).type === 'MemberExpression' )) { return; } } if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') { return; } if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') { return; } // Skip for empty parentheses if (value === '(') { return; } errors.assert.whitespaceBetween({ token: prevToken, nextToken: token, message: 'Missing space before closing round bracket' }); }); } |
| Function (anonymous_1195) | |
|---|---|
| ✓ Was called | file.iterateTokenByValue('(', function(token) {··· var nextToken = file.getNextToken(token, {includeComments: true}); var value = nextToken.value; if ( ignoreParenthesizedExpression && TokenCategorizer.categorizeOpenParen(token, file) === 'ParenthesizedExpression' ) { return; } if (value in exceptions) { return; } if (doubleQuote && nextToken.type === 'String' && value[0] === '"') { return; } if (singleQuote && nextToken.type === 'String' && value[0] === '\'') { return; } // Skip for empty parentheses if (value === ')') { return; } errors.assert.whitespaceBetween({ token: token, nextToken: nextToken, message: 'Missing space after opening round bracket' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | ) {··· return; } |
| ✓ Negative was executed (else) | }··· if (value in exceptions) { |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | TokenCategorizer.categorizeOpenParen(token, file) === 'ParenthesizedExpression' |
| ✓ Was returned | ignoreParenthesizedExpression && |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value in exceptions) {··· return; } |
| ✓ Negative was executed (else) | }··· if (doubleQuote && nextToken.type === 'String' && value[0] === '"') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (doubleQuote && nextToken.type === 'String' && value[0] === '"') {··· return; } |
| ✓ Negative was executed (else) | }··· if (singleQuote && nextToken.type === 'String' && value[0] === '\'') { |
| Branch LogicalExpression | |
| ✓ Was returned | if (doubleQuote && nextToken.type === 'String' && value[0] === '"') { |
| ✓ Was returned | if (doubleQuote && nextToken.type === 'String' && value[0] === '"') { |
| Branch LogicalExpression | |
| ✓ Was returned | if (doubleQuote && nextToken.type === 'String' && value[0] === '"') { |
| ✓ Was returned | if (doubleQuote && nextToken.type === 'String' && value[0] === '"') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (singleQuote && nextToken.type === 'String' && value[0] === '\'') {··· return; } |
| ✓ Negative was executed (else) | }··· // Skip for empty parentheses |
| Branch LogicalExpression | |
| ✓ Was returned | if (singleQuote && nextToken.type === 'String' && value[0] === '\'') { |
| ✓ Was returned | if (singleQuote && nextToken.type === 'String' && value[0] === '\'') { |
| Branch LogicalExpression | |
| ✓ Was returned | if (singleQuote && nextToken.type === 'String' && value[0] === '\'') { |
| ✓ Was returned | if (singleQuote && nextToken.type === 'String' && value[0] === '\'') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value === ')') {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.whitespaceBetween({ |
| Function (anonymous_1196) | |
|---|---|
| ✓ Was called | file.iterateTokenByValue(')', function(token) {··· var prevToken = file.getPrevToken(token, {includeComments: true}); var value = prevToken.value; if ( ignoreParenthesizedExpression && TokenCategorizer.categorizeCloseParen(token, file) === 'ParenthesizedExpression' ) { return; } if (value in exceptions) { // Special case - foo( object[i] ) if (!( value === ']' && file.getNodeByRange(token.range[0] - 1).type === 'MemberExpression' )) { return; } } if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') { return; } if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') { return; } // Skip for empty parentheses if (value === '(') { return; } errors.assert.whitespaceBetween({ token: prevToken, nextToken: token, message: 'Missing space before closing round bracket' }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | ) {··· return; } |
| ✓ Negative was executed (else) | }··· if (value in exceptions) { |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | TokenCategorizer.categorizeCloseParen(token, file) === 'ParenthesizedExpression' |
| ✓ Was returned | ignoreParenthesizedExpression && |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value in exceptions) {··· // Special case - foo( object[i] ) if (!( value === ']' && file.getNodeByRange(token.range[0] - 1).type === 'MemberExpression' )) { return; } } |
| ✓ Negative was executed (else) | }··· if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | )) {··· return; } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | file.getNodeByRange(token.range[0] - 1).type === 'MemberExpression' |
| ✓ Was returned | value === ']' && |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') {··· return; } |
| ✓ Negative was executed (else) | }··· if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') { |
| Branch LogicalExpression | |
| ✓ Was returned | if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') { |
| ✓ Was returned | if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') { |
| Branch LogicalExpression | |
| ✓ Was returned | if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') { |
| ✓ Was returned | if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') {··· return; } |
| ✓ Negative was executed (else) | }··· // Skip for empty parentheses |
| Branch LogicalExpression | |
| ✓ Was returned | if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') { |
| ✓ Was returned | if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') { |
| Branch LogicalExpression | |
| ✓ Was returned | if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') { |
| ✓ Was returned | if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value === '(') {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.whitespaceBetween({ |
| Function (anonymous_1197) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1198) | |
|---|---|
| ✓ Was called | configure: function(value) {··· var isObject = typeof value === 'object'; var error = this.getOptionName() + ' rule requires string value true or object'; if (isObject) { assert('allExcept' in value, error); } else { assert(value === true, error); } this._exceptions = {}; if (isObject) { (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isObject) {··· assert('allExcept' in value, error); } else { |
| ✓ Negative was executed (else) | } else {··· assert(value === true, error); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isObject) {··· (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } |
| ✓ Negative was executed (else) | }··· }, |
| Function (anonymous_1199) | |
|---|---|
| ✓ Was called | (value.allExcept || []).forEach(function(value) {··· this._exceptions[value] = true; }, this); |
| Branch LogicalExpression | |
| ✗ Was not returned | (value.allExcept || []).forEach(function(value) { |
| ✓ Was returned | (value.allExcept || []).forEach(function(value) { |
| Function (anonymous_1200) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpacesInsideParenthesizedExpression'; }, |
| Function (anonymous_1201) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var exceptions = this._exceptions; file.iterateTokenByValue('(', function(token) { var nextToken = file.getNextToken(token, {includeComments: true}); var value = nextToken.isComment ? nextToken.type === 'Block' ? '/*' : '//' : nextToken.value; // Skip empty parentheses and explicit exceptions if (value === ')' || value in exceptions) { return; } // Skip non-expression parentheses var type = TokenCategorizer.categorizeOpenParen(token, file); if (type !== 'ParenthesizedExpression') { return; } errors.assert.whitespaceBetween({ token: token, nextToken: nextToken, message: 'Missing space after opening grouping parenthesis' }); }); file.iterateTokenByValue(')', function(token) { var prevToken = file.getPrevToken(token, {includeComments: true}); var value = prevToken.isComment ? prevToken.type === 'Block' ? '*/' : '' : prevToken.value; // Skip empty parentheses and explicit exceptions if (value === '(' || value in exceptions) { return; } // Skip non-expression parentheses var type = TokenCategorizer.categorizeCloseParen(token, file); if (type !== 'ParenthesizedExpression') { return; } errors.assert.whitespaceBetween({ token: prevToken, nextToken: token, message: 'Missing space before closing grouping parenthesis' }); }); } |
| Function (anonymous_1202) | |
|---|---|
| ✓ Was called | file.iterateTokenByValue('(', function(token) {··· var nextToken = file.getNextToken(token, {includeComments: true}); var value = nextToken.isComment ? nextToken.type === 'Block' ? '/*' : '//' : nextToken.value; // Skip empty parentheses and explicit exceptions if (value === ')' || value in exceptions) { return; } // Skip non-expression parentheses var type = TokenCategorizer.categorizeOpenParen(token, file); if (type !== 'ParenthesizedExpression') { return; } errors.assert.whitespaceBetween({ token: token, nextToken: nextToken, message: 'Missing space after opening grouping parenthesis' }); }); |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | nextToken.type === 'Block' ? '/*' : '//' : |
| ✓ Negative was returned (: ...) | nextToken.value; |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | nextToken.type === 'Block' ? '/*' : '//' : |
| ✓ Negative was returned (: ...) | nextToken.type === 'Block' ? '/*' : '//' : |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value === ')' || value in exceptions) {··· return; } |
| ✓ Negative was executed (else) | }··· // Skip non-expression parentheses |
| Branch LogicalExpression | |
| ✓ Was returned | if (value === ')' || value in exceptions) { |
| ✓ Was returned | if (value === ')' || value in exceptions) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (type !== 'ParenthesizedExpression') {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.whitespaceBetween({ |
| Function (anonymous_1203) | |
|---|---|
| ✓ Was called | file.iterateTokenByValue(')', function(token) {··· var prevToken = file.getPrevToken(token, {includeComments: true}); var value = prevToken.isComment ? prevToken.type === 'Block' ? '*/' : '' : prevToken.value; // Skip empty parentheses and explicit exceptions if (value === '(' || value in exceptions) { return; } // Skip non-expression parentheses var type = TokenCategorizer.categorizeCloseParen(token, file); if (type !== 'ParenthesizedExpression') { return; } errors.assert.whitespaceBetween({ token: prevToken, nextToken: token, message: 'Missing space before closing grouping parenthesis' }); }); |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | prevToken.type === 'Block' ? '*/' : '' : |
| ✓ Negative was returned (: ...) | prevToken.value; |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | prevToken.type === 'Block' ? '*/' : '' : |
| ✓ Negative was returned (: ...) | prevToken.type === 'Block' ? '*/' : '' : |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (value === '(' || value in exceptions) {··· return; } |
| ✓ Negative was executed (else) | }··· // Skip non-expression parentheses |
| Branch LogicalExpression | |
| ✓ Was returned | if (value === '(' || value in exceptions) { |
| ✓ Was returned | if (value === '(' || value in exceptions) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (type !== 'ParenthesizedExpression') {··· return; } |
| ✓ Negative was executed (else) | }··· errors.assert.whitespaceBetween({ |
| Function (anonymous_1204) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1205) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
| Function (anonymous_1206) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireSpread'; }, |
| Function (anonymous_1207) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('CallExpression', function(node) { var callee = node.callee; var firstParameter = node.arguments[0]; if (node.arguments.length === 2 && callee.property && callee.property.name === 'apply' && callee.object && callee.object.name === firstParameter.name) { errors.add( 'Illegal use of apply method. Use the spread operator instead', node.callee.property.loc.start ); } }); } |
| Function (anonymous_1208) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('CallExpression', function(node) {··· var callee = node.callee; var firstParameter = node.arguments[0]; if (node.arguments.length === 2 && callee.property && callee.property.name === 'apply' && callee.object && callee.object.name === firstParameter.name) { errors.add( 'Illegal use of apply method. Use the spread operator instead', node.callee.property.loc.start ); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | callee.object && callee.object.name === firstParameter.name) {··· errors.add( 'Illegal use of apply method. Use the spread operator instead', node.callee.property.loc.start ); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | callee.object && callee.object.name === firstParameter.name) { |
| ✓ Was returned | if (node.arguments.length === 2 &&··· callee.property && callee.property.name === 'apply' && callee.object && callee.object.name === firstParameter.name) { |
| Branch LogicalExpression | |
| ✓ Was returned | callee.object && callee.object.name === firstParameter.name) { |
| ✓ Was returned | if (node.arguments.length === 2 &&··· callee.property && callee.property.name === 'apply' && |
| Branch LogicalExpression | |
| ✓ Was returned | callee.property && callee.property.name === 'apply' && |
| ✓ Was returned | if (node.arguments.length === 2 &&··· callee.property && callee.property.name === 'apply' && |
| Branch LogicalExpression | |
| ✓ Was returned | callee.property && callee.property.name === 'apply' && |
| ✓ Was returned | if (node.arguments.length === 2 && |
| Function (anonymous_1209) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1210) | |
|---|---|
| ✓ Was called | configure: function(options) {··· this._allowStringConcatenation = false; var optionName = this.getOptionName(); if (typeof options === 'object') { assert(Array.isArray(options.allExcept), optionName + ' option requires "allExcept" ' + 'to be an array'); assert(options.allExcept.length > 0, optionName + ' option requires "allExcept" ' + 'to have at least one item or be set to `true`'); options.allExcept.forEach(function(except) { if (except === 'stringConcatenation') { this._allowStringConcatenation = true; } else { assert(false, optionName + ' option requires "allExcept" to only have ' + '"stringConcatenation"'); } }, this); } else { assert( options === true, optionName + ' option requires true value or object' ); } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof options === 'object') {··· assert(Array.isArray(options.allExcept), optionName + ' option requires "allExcept" ' + 'to be an array'); assert(options.allExcept.length > 0, optionName + ' option requires "allExcept" ' + 'to have at least one item or be set to `true`'); options.allExcept.forEach(function(except) { if (except === 'stringConcatenation') { this._allowStringConcatenation = true; } else { assert(false, optionName + ' option requires "allExcept" to only have ' + '"stringConcatenation"'); } }, this); } else { |
| ✓ Negative was executed (else) | } else {··· assert( options === true, optionName + ' option requires true value or object' ); } |
| Function (anonymous_1211) | |
|---|---|
| ✓ Was called | options.allExcept.forEach(function(except) {··· if (except === 'stringConcatenation') { this._allowStringConcatenation = true; } else { assert(false, optionName + ' option requires "allExcept" to only have ' + '"stringConcatenation"'); } }, this); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (except === 'stringConcatenation') {··· this._allowStringConcatenation = true; } else { |
| ✓ Negative was executed (else) | } else {··· assert(false, optionName + ' option requires "allExcept" to only have ' + '"stringConcatenation"'); } |
| Function (anonymous_1212) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireTemplateStrings'; }, |
| Function (anonymous_1213) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var allowStringConcatenation = this._allowStringConcatenation; function add(node) { errors.add( 'Illegal use of string concatenation. Use template strings instead.', node.left.loc.end ); } file.iterateNodesByType('BinaryExpression', function(node) { if (node.operator !== '+') { return; } var leftIsString = node.left; var rightIsString = node.right; // Left side could also be binary expression (See gh-2050), // but not the right one while (leftIsString.type === 'BinaryExpression') { leftIsString = leftIsString.left; } leftIsString = typeof leftIsString.value === 'string' || leftIsString.type === 'TemplateLiteral'; rightIsString = typeof rightIsString.value === 'string' || rightIsString.type === 'TemplateLiteral'; if (allowStringConcatenation && leftIsString && rightIsString) { return; } // At least one of the operands should be a string or template string, // otherwise this is not a concatenation if (leftIsString || rightIsString) { add(node); } }); } |
| Function add | |
|---|---|
| ✓ Was called | function add(node) {··· errors.add( 'Illegal use of string concatenation. Use template strings instead.', node.left.loc.end ); } |
| Function (anonymous_1215) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('BinaryExpression', function(node) {··· if (node.operator !== '+') { return; } var leftIsString = node.left; var rightIsString = node.right; // Left side could also be binary expression (See gh-2050), // but not the right one while (leftIsString.type === 'BinaryExpression') { leftIsString = leftIsString.left; } leftIsString = typeof leftIsString.value === 'string' || leftIsString.type === 'TemplateLiteral'; rightIsString = typeof rightIsString.value === 'string' || rightIsString.type === 'TemplateLiteral'; if (allowStringConcatenation && leftIsString && rightIsString) { return; } // At least one of the operands should be a string or template string, // otherwise this is not a concatenation if (leftIsString || rightIsString) { add(node); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.operator !== '+') {··· return; } |
| ✓ Negative was executed (else) | }··· var leftIsString = node.left; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | leftIsString.type === 'TemplateLiteral'; |
| ✓ Was returned | leftIsString = typeof leftIsString.value === 'string' || |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | rightIsString.type === 'TemplateLiteral'; |
| ✓ Was returned | rightIsString = typeof rightIsString.value === 'string' || |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (allowStringConcatenation && leftIsString && rightIsString) {··· return; } |
| ✓ Negative was executed (else) | }··· // At least one of the operands should be a string or template string, |
| Branch LogicalExpression | |
| ✓ Was returned | if (allowStringConcatenation && leftIsString && rightIsString) { |
| ✓ Was returned | if (allowStringConcatenation && leftIsString && rightIsString) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (allowStringConcatenation && leftIsString && rightIsString) { |
| ✓ Was returned | if (allowStringConcatenation && leftIsString && rightIsString) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (leftIsString || rightIsString) {··· add(node); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | if (leftIsString || rightIsString) { |
| ✓ Was returned | if (leftIsString || rightIsString) { |
| Function (anonymous_1216) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1217) | |
|---|---|
| ✓ Was called | configure: function(options) {··· if (typeof options === 'object') { if ('ignoreSingleValue' in options) { assert( options.ignoreSingleValue === true, this.getOptionName() + ' option ignoreSingleValue requires true value or should be removed' ); this._ignoreSingleValue = true; } if ('ignoreSingleLine' in options) { assert( options.ignoreSingleLine === true, this.getOptionName() + ' option ignoreSingleLine requires true value or should be removed' ); this._ignoreSingleLine = true; } } else { assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); } }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof options === 'object') {··· if ('ignoreSingleValue' in options) { assert( options.ignoreSingleValue === true, this.getOptionName() + ' option ignoreSingleValue requires true value or should be removed' ); this._ignoreSingleValue = true; } if ('ignoreSingleLine' in options) { assert( options.ignoreSingleLine === true, this.getOptionName() + ' option ignoreSingleLine requires true value or should be removed' ); this._ignoreSingleLine = true; } } else { |
| ✓ Negative was executed (else) | } else {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('ignoreSingleValue' in options) {··· assert( options.ignoreSingleValue === true, this.getOptionName() + ' option ignoreSingleValue requires true value or should be removed' ); this._ignoreSingleValue = true; } |
| ✓ Negative was executed (else) | }··· if ('ignoreSingleLine' in options) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('ignoreSingleLine' in options) {··· assert( options.ignoreSingleLine === true, this.getOptionName() + ' option ignoreSingleLine requires true value or should be removed' ); this._ignoreSingleLine = true; } |
| ✓ Negative was executed (else) | }··· } else { |
| Function (anonymous_1218) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireTrailingComma'; }, |
| Function (anonymous_1219) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var _this = this; file.iterateNodesByType([ 'ObjectExpression', 'ArrayExpression', 'ObjectPattern', 'ArrayPattern' ], function(node) { var isLikeObject = node.type === 'ObjectExpression' || node.type === 'ObjectPattern'; var entities = isLikeObject ? node.properties : node.elements; if (entities.length === 0) { return; } if (_this._ignoreSingleValue && entities.length === 1) { return; } if (_this._ignoreSingleLine && node.loc.start.line === node.loc.end.line) { return; } var closingToken = file.getLastNodeToken(node); errors.assert.tokenBefore({ token: closingToken, expectedTokenBefore: {type: 'Punctuator', value: ','}, message: 'Missing comma before closing ' + (isLikeObject ? 'curly brace' : 'bracket') }); }); } |
| Function (anonymous_1220) | |
|---|---|
| ✓ Was called | ], function(node) {··· var isLikeObject = node.type === 'ObjectExpression' || node.type === 'ObjectPattern'; var entities = isLikeObject ? node.properties : node.elements; if (entities.length === 0) { return; } if (_this._ignoreSingleValue && entities.length === 1) { return; } if (_this._ignoreSingleLine && node.loc.start.line === node.loc.end.line) { return; } var closingToken = file.getLastNodeToken(node); errors.assert.tokenBefore({ token: closingToken, expectedTokenBefore: {type: 'Punctuator', value: ','}, message: 'Missing comma before closing ' + (isLikeObject ? 'curly brace' : 'bracket') }); }); |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | var isLikeObject = node.type === 'ObjectExpression' || node.type === 'ObjectPattern'; |
| ✓ Was returned | var isLikeObject = node.type === 'ObjectExpression' || node.type === 'ObjectPattern'; |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | var entities = isLikeObject ? node.properties : node.elements; |
| ✓ Negative was returned (: ...) | var entities = isLikeObject ? node.properties : node.elements; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (entities.length === 0) {··· return; } |
| ✓ Negative was executed (else) | }··· if (_this._ignoreSingleValue && entities.length === 1) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (_this._ignoreSingleValue && entities.length === 1) {··· return; } |
| ✓ Negative was executed (else) | }··· if (_this._ignoreSingleLine && node.loc.start.line === node.loc.end.line) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (_this._ignoreSingleValue && entities.length === 1) { |
| ✓ Was returned | if (_this._ignoreSingleValue && entities.length === 1) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (_this._ignoreSingleLine && node.loc.start.line === node.loc.end.line) {··· return; } |
| ✓ Negative was executed (else) | }··· var closingToken = file.getLastNodeToken(node); |
| Branch LogicalExpression | |
| ✓ Was returned | if (_this._ignoreSingleLine && node.loc.start.line === node.loc.end.line) { |
| ✓ Was returned | if (_this._ignoreSingleLine && node.loc.start.line === node.loc.end.line) { |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | message: 'Missing comma before closing ' + (isLikeObject ? 'curly brace' : 'bracket') |
| ✓ Negative was returned (: ...) | message: 'Missing comma before closing ' + (isLikeObject ? 'curly brace' : 'bracket') |
| Function getVariableScope | |
|---|---|
| ✓ Was called | function getVariableScope(node) {··· while (node.type !== 'Program' && node.type !== 'FunctionDeclaration' && node.type !== 'FunctionExpression') { node = node.parentNode; } return node; } |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | node.type !== 'FunctionExpression') { |
| ✓ Was returned | while (node.type !== 'Program' &&··· node.type !== 'FunctionDeclaration' && |
| Branch LogicalExpression | |
| ✓ Was returned | node.type !== 'FunctionDeclaration' && |
| ✓ Was returned | while (node.type !== 'Program' && |
| Function getOffsetForBlockStatement | |
|---|---|
| ✓ Was called | function getOffsetForBlockStatement(enclosingScope, varDecl, commentTokens, file) {··· var offset = 0; var parentNode = varDecl.parentNode; if (enclosingScope.type !== 'Program' && parentNode.type === 'BlockStatement') { offset += 1; offset += getCommentOffsetBetweenNodes(parentNode, varDecl, commentTokens, file); } return offset; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (enclosingScope.type !== 'Program' && parentNode.type === 'BlockStatement') {··· offset += 1; offset += getCommentOffsetBetweenNodes(parentNode, varDecl, commentTokens, file); } |
| ✓ Negative was executed (else) | }··· return offset; |
| Branch LogicalExpression | |
| ✓ Was returned | if (enclosingScope.type !== 'Program' && parentNode.type === 'BlockStatement') { |
| ✓ Was returned | if (enclosingScope.type !== 'Program' && parentNode.type === 'BlockStatement') { |
| Function getUseStrictDeclFirst | |
|---|---|
| ✓ Was called | function getUseStrictDeclFirst(enclosingScope) {··· var firstNode; if (enclosingScope.type === 'Program') { firstNode = enclosingScope.body[0]; } else { firstNode = enclosingScope.body.body[0]; } if (firstNode.type === 'ExpressionStatement' && firstNode.hasOwnProperty('expression') === true && firstNode.expression.hasOwnProperty('value') === true && firstNode.expression.value === 'use strict') { return firstNode; } return null; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (enclosingScope.type === 'Program') {··· firstNode = enclosingScope.body[0]; } else { |
| ✓ Negative was executed (else) | } else {··· firstNode = enclosingScope.body.body[0]; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | firstNode.expression.value === 'use strict') {··· return firstNode; } |
| ✓ Negative was executed (else) | }··· return null; |
| Branch LogicalExpression | |
| ✓ Was returned | firstNode.expression.value === 'use strict') { |
| ✓ Was returned | if (firstNode.type === 'ExpressionStatement' &&··· firstNode.hasOwnProperty('expression') === true && firstNode.expression.hasOwnProperty('value') === true && |
| Branch LogicalExpression | |
| ✓ Was returned | firstNode.expression.hasOwnProperty('value') === true && |
| ✓ Was returned | if (firstNode.type === 'ExpressionStatement' &&··· firstNode.hasOwnProperty('expression') === true && |
| Branch LogicalExpression | |
| ✓ Was returned | firstNode.hasOwnProperty('expression') === true && |
| ✓ Was returned | if (firstNode.type === 'ExpressionStatement' && |
| Function isFirstVarDeclInScope | |
|---|---|
| ✓ Was called | function isFirstVarDeclInScope(enclosingScope, varDecl, whitespaceOffsetBeforeVarDecl, commentTokens, file) {··· var adjustedVarDeclStart = varDecl.range[0]; var adjustedScopeStart = enclosingScope.range[0]; if (enclosingScope.type !== 'Program') { // For function declaration and function expression scope use the top block statement as start // This removes the requirement to offset the function declaration or expression related tokens adjustedScopeStart = enclosingScope.body.range[0]; // If enclosing scope node type is Program the range start ignores all comments and whitespace before the // variable declaration adjustedVarDeclStart -= whitespaceOffsetBeforeVarDecl; } adjustedVarDeclStart -= getOffsetForBlockStatement(enclosingScope, varDecl, commentTokens, file); if (adjustedVarDeclStart === adjustedScopeStart) { return true; } return false; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (enclosingScope.type !== 'Program') {··· // For function declaration and function expression scope use the top block statement as start // This removes the requirement to offset the function declaration or expression related tokens adjustedScopeStart = enclosingScope.body.range[0]; // If enclosing scope node type is Program the range start ignores all comments and whitespace before the // variable declaration adjustedVarDeclStart -= whitespaceOffsetBeforeVarDecl; } |
| ✓ Negative was executed (else) | }··· adjustedVarDeclStart -= getOffsetForBlockStatement(enclosingScope, varDecl, commentTokens, file); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (adjustedVarDeclStart === adjustedScopeStart) {··· return true; } |
| ✓ Negative was executed (else) | }··· return false; |
| Function getCommentOffsetBetweenNodes | |
|---|---|
| ✓ Was called | function getCommentOffsetBetweenNodes(previousNode, currentNode, commentTokens, file) {··· var count; var comment; var commentLength = 0; for (count = 0; count < commentTokens.length; count++) { comment = commentTokens[count]; if (comment.range[0] >= currentNode.range[1]) { // Stop processing comments that are occurred after current node break; } if (previousNode.range[1] < currentNode.range[0] && comment.range[0] > previousNode.range[0] && comment.range[1] < previousNode.range[1]) { // Stop processing comments that are within multiple declarators in a single variable declaration // of the previous node and the previousNode is not the parent of currentNode break; } if (comment.range[0] > currentNode.range[0] && comment.range[1] < currentNode.range[1]) { // Stop processing comments that are within multiple declarators in a single variable declaration break; } if (previousNode.range[0] >= comment.range[1]) { // Skip comments that occurred before the previous node continue; } commentLength += comment.range[1] - comment.range[0] + file.getWhitespaceBefore(comment).length; } return commentLength; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (comment.range[0] >= currentNode.range[1]) {··· // Stop processing comments that are occurred after current node break; } |
| ✓ Negative was executed (else) | }··· if (previousNode.range[1] < currentNode.range[0] && |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | comment.range[1] < previousNode.range[1]) {··· // Stop processing comments that are within multiple declarators in a single variable declaration // of the previous node and the previousNode is not the parent of currentNode break; } |
| ✓ Negative was executed (else) | }··· if (comment.range[0] > currentNode.range[0] && |
| Branch LogicalExpression | |
| ✓ Was returned | comment.range[1] < previousNode.range[1]) { |
| ✓ Was returned | if (previousNode.range[1] < currentNode.range[0] &&··· comment.range[0] > previousNode.range[0] && |
| Branch LogicalExpression | |
| ✓ Was returned | comment.range[0] > previousNode.range[0] && |
| ✓ Was returned | if (previousNode.range[1] < currentNode.range[0] && |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | comment.range[1] < currentNode.range[1]) {··· // Stop processing comments that are within multiple declarators in a single variable declaration break; } |
| ✓ Negative was executed (else) | }··· if (previousNode.range[0] >= comment.range[1]) { |
| Branch LogicalExpression | |
| ✓ Was returned | comment.range[1] < currentNode.range[1]) { |
| ✓ Was returned | if (comment.range[0] > currentNode.range[0] && |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (previousNode.range[0] >= comment.range[1]) {··· // Skip comments that occurred before the previous node continue; } |
| ✓ Negative was executed (else) | }··· commentLength += comment.range[1] - comment.range[0] + file.getWhitespaceBefore(comment).length; |
| Function isPreviousNodeAVarDecl | |
|---|---|
| ✓ Was called | function isPreviousNodeAVarDecl(previousNode, varDecl, whitespaceOffsetBeforeVarDecl, commentTokens, file) {··· var offsetForComments; if (varDecl.range[0] === previousNode.range[1]) { return true; } offsetForComments = getCommentOffsetBetweenNodes(previousNode, varDecl, commentTokens, file); if (varDecl.range[0] - whitespaceOffsetBeforeVarDecl - offsetForComments === previousNode.range[1]) { return true; } return false; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (varDecl.range[0] === previousNode.range[1]) {··· return true; } |
| ✓ Negative was executed (else) | }··· offsetForComments = getCommentOffsetBetweenNodes(previousNode, varDecl, commentTokens, file); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (varDecl.range[0] - whitespaceOffsetBeforeVarDecl - offsetForComments === previousNode.range[1]) {··· return true; } |
| ✓ Negative was executed (else) | }··· return false; |
| Function (anonymous_1227) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1228) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value' ); }, |
| Function (anonymous_1229) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireVarDeclFirst'; }, |
| Function (anonymous_1230) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var scopesFoundInFile = {}; var commentTokens = []; file.iterateTokensByType(['Line', 'Block'], function(commentToken) { commentTokens.push(commentToken); }); file.iterateNodesByType(['VariableDeclaration'], function(varDecl) { // Ignore let and const for now #1783 if (varDecl.kind !== 'var') { return; } var enclosingScope; var scopeContents; var previousNode; var useStrictDirective; var isVarDeclFirst = false; var whitespaceOffsetBeforeVarDecl = file.getWhitespaceBefore(file.getFirstNodeToken(varDecl)).length; enclosingScope = getVariableScope(varDecl.parentNode); if (!scopesFoundInFile.hasOwnProperty(enclosingScope.range[0])) { scopesFoundInFile[enclosingScope.range[0]] = { hasNonVarDecl: false, varDecl: [] }; // placing the handling 'use strict' declared as the first statement of scope here to improve // performance to run once per scope discovered in file useStrictDirective = getUseStrictDeclFirst(enclosingScope); if (useStrictDirective !== null) { // Special case to make varDecl stack contain the use strict as first node // this reduces the complexity of the isFirstVarDecInScope and reuses // isPreviousNodeAVarDecl to handle this special scenario scopesFoundInFile[enclosingScope.range[0]].varDecl.push(useStrictDirective); } } scopeContents = scopesFoundInFile[enclosingScope.range[0]]; if (scopeContents.varDecl.length === 0) { isVarDeclFirst = isFirstVarDeclInScope( enclosingScope, varDecl, whitespaceOffsetBeforeVarDecl, commentTokens, file ); } else { previousNode = scopeContents.varDecl[scopeContents.varDecl.length - 1]; if (!scopeContents.hasNonVarDecl) { isVarDeclFirst = isPreviousNodeAVarDecl( previousNode, varDecl, whitespaceOffsetBeforeVarDecl, commentTokens, file ); } } scopeContents.varDecl.push(varDecl); if (!isVarDeclFirst) { scopeContents.hasNonVarDecl = true; errors.add('Variable declarations must be the first statements of a function scope.', varDecl.loc.start.line, varDecl.loc.start.column); } }); } |
| Function (anonymous_1231) | |
|---|---|
| ✓ Was called | file.iterateTokensByType(['Line', 'Block'], function(commentToken) {··· commentTokens.push(commentToken); }); |
| Function (anonymous_1232) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['VariableDeclaration'], function(varDecl) {··· // Ignore let and const for now #1783 if (varDecl.kind !== 'var') { return; } var enclosingScope; var scopeContents; var previousNode; var useStrictDirective; var isVarDeclFirst = false; var whitespaceOffsetBeforeVarDecl = file.getWhitespaceBefore(file.getFirstNodeToken(varDecl)).length; enclosingScope = getVariableScope(varDecl.parentNode); if (!scopesFoundInFile.hasOwnProperty(enclosingScope.range[0])) { scopesFoundInFile[enclosingScope.range[0]] = { hasNonVarDecl: false, varDecl: [] }; // placing the handling 'use strict' declared as the first statement of scope here to improve // performance to run once per scope discovered in file useStrictDirective = getUseStrictDeclFirst(enclosingScope); if (useStrictDirective !== null) { // Special case to make varDecl stack contain the use strict as first node // this reduces the complexity of the isFirstVarDecInScope and reuses // isPreviousNodeAVarDecl to handle this special scenario scopesFoundInFile[enclosingScope.range[0]].varDecl.push(useStrictDirective); } } scopeContents = scopesFoundInFile[enclosingScope.range[0]]; if (scopeContents.varDecl.length === 0) { isVarDeclFirst = isFirstVarDeclInScope( enclosingScope, varDecl, whitespaceOffsetBeforeVarDecl, commentTokens, file ); } else { previousNode = scopeContents.varDecl[scopeContents.varDecl.length - 1]; if (!scopeContents.hasNonVarDecl) { isVarDeclFirst = isPreviousNodeAVarDecl( previousNode, varDecl, whitespaceOffsetBeforeVarDecl, commentTokens, file ); } } scopeContents.varDecl.push(varDecl); if (!isVarDeclFirst) { scopeContents.hasNonVarDecl = true; errors.add('Variable declarations must be the first statements of a function scope.', varDecl.loc.start.line, varDecl.loc.start.column); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (varDecl.kind !== 'var') {··· return; } |
| ✓ Negative was executed (else) | }··· var enclosingScope; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!scopesFoundInFile.hasOwnProperty(enclosingScope.range[0])) {··· scopesFoundInFile[enclosingScope.range[0]] = { hasNonVarDecl: false, varDecl: [] }; // placing the handling 'use strict' declared as the first statement of scope here to improve // performance to run once per scope discovered in file useStrictDirective = getUseStrictDeclFirst(enclosingScope); if (useStrictDirective !== null) { // Special case to make varDecl stack contain the use strict as first node // this reduces the complexity of the isFirstVarDecInScope and reuses // isPreviousNodeAVarDecl to handle this special scenario scopesFoundInFile[enclosingScope.range[0]].varDecl.push(useStrictDirective); } } |
| ✓ Negative was executed (else) | }··· scopeContents = scopesFoundInFile[enclosingScope.range[0]]; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (useStrictDirective !== null) {··· // Special case to make varDecl stack contain the use strict as first node // this reduces the complexity of the isFirstVarDecInScope and reuses // isPreviousNodeAVarDecl to handle this special scenario scopesFoundInFile[enclosingScope.range[0]].varDecl.push(useStrictDirective); } |
| ✓ Negative was executed (else) | }··· } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (scopeContents.varDecl.length === 0) {··· isVarDeclFirst = isFirstVarDeclInScope( enclosingScope, varDecl, whitespaceOffsetBeforeVarDecl, commentTokens, file ); } else { |
| ✓ Negative was executed (else) | } else {··· previousNode = scopeContents.varDecl[scopeContents.varDecl.length - 1]; if (!scopeContents.hasNonVarDecl) { isVarDeclFirst = isPreviousNodeAVarDecl( previousNode, varDecl, whitespaceOffsetBeforeVarDecl, commentTokens, file ); } } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!scopeContents.hasNonVarDecl) {··· isVarDeclFirst = isPreviousNodeAVarDecl( previousNode, varDecl, whitespaceOffsetBeforeVarDecl, commentTokens, file ); } |
| ✓ Negative was executed (else) | }··· } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!isVarDeclFirst) {··· scopeContents.hasNonVarDecl = true; errors.add('Variable declarations must be the first statements of a function scope.', varDecl.loc.start.line, varDecl.loc.start.column); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_1233) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1234) | |
|---|---|
| ✓ Was called | configure: function(operators) {··· var isTrue = operators === true; assert( Array.isArray(operators) || isTrue, this.getOptionName() + ' option requires array or true value' ); if (isTrue) { operators = ['==', '===', '!=', '!==']; } this._operatorIndex = {}; for (var i = 0, l = operators.length; i < l; i++) { this._operatorIndex[operators[i]] = true; } }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | Array.isArray(operators) || isTrue, |
| ✓ Was returned | Array.isArray(operators) || isTrue, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isTrue) {··· operators = ['==', '===', '!=', '!==']; } |
| ✓ Negative was executed (else) | }··· this._operatorIndex = {}; |
| Function (anonymous_1235) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'requireYodaConditions'; }, |
| Function (anonymous_1236) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var operators = this._operatorIndex; file.iterateNodesByType('BinaryExpression', function(node) { if (operators[node.operator]) { if (node.right.type === 'Literal' || (node.right.type === 'Identifier' && node.right.name === 'undefined') ) { errors.add('Not yoda condition', node.left.loc.start); } } }); } |
| Function (anonymous_1237) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('BinaryExpression', function(node) {··· if (operators[node.operator]) { if (node.right.type === 'Literal' || (node.right.type === 'Identifier' && node.right.name === 'undefined') ) { errors.add('Not yoda condition', node.left.loc.start); } } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (operators[node.operator]) {··· if (node.right.type === 'Literal' || (node.right.type === 'Identifier' && node.right.name === 'undefined') ) { errors.add('Not yoda condition', node.left.loc.start); } } |
| ✓ Negative was executed (else) | }··· }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | ) {··· errors.add('Not yoda condition', node.left.loc.start); } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | (node.right.type === 'Identifier' && node.right.name === 'undefined') |
| ✓ Was returned | if (node.right.type === 'Literal' || |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | (node.right.type === 'Identifier' && node.right.name === 'undefined') |
| ✓ Was returned | (node.right.type === 'Identifier' && node.right.name === 'undefined') |
| Function (anonymous_1238) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1239) | |
|---|---|
| ✓ Was called | configure: function(keywords) {··· assert( Array.isArray(keywords) || typeof keywords === 'string', this.getOptionName() + ' option requires string or array value' ); this._keywords = keywords; }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | Array.isArray(keywords) || typeof keywords === 'string', |
| ✓ Was returned | Array.isArray(keywords) || typeof keywords === 'string', |
| Function (anonymous_1240) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'safeContextKeyword'; }, |
| Function (anonymous_1241) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var keywords = typeof this._keywords === 'string' ? [this._keywords] : this._keywords; // var that = this file.iterateNodesByType('VariableDeclaration', function(node) { var firstToken = file.getFirstNodeToken(node); // Miss destructing assignment (#1699) if (file.getNextToken(firstToken).value === '{') { return; } for (var i = 0; i < node.declarations.length; i++) { var decl = node.declarations[i]; // decl.init === null in case of "var foo;" if (decl.init && (decl.init.type === 'ThisExpression' && checkKeywords(decl.id.name, keywords)) ) { errors.add( 'You should use "' + keywords.join('" or "') + '" to save a reference to "this"', node.loc.start ); } } }); // that = this file.iterateNodesByType('AssignmentExpression', function(node) { if ( // filter property assignments "foo.bar = this" node.left.type === 'Identifier' && (node.right.type === 'ThisExpression' && checkKeywords(node.left.name, keywords)) ) { errors.add( 'You should use "' + keywords.join('" or "') + '" to save a reference to "this"', node.loc.start ); } }); } |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | var keywords = typeof this._keywords === 'string' ? [this._keywords] : this._keywords; |
| ✓ Negative was returned (: ...) | var keywords = typeof this._keywords === 'string' ? [this._keywords] : this._keywords; |
| Function (anonymous_1242) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('VariableDeclaration', function(node) {··· var firstToken = file.getFirstNodeToken(node); // Miss destructing assignment (#1699) if (file.getNextToken(firstToken).value === '{') { return; } for (var i = 0; i < node.declarations.length; i++) { var decl = node.declarations[i]; // decl.init === null in case of "var foo;" if (decl.init && (decl.init.type === 'ThisExpression' && checkKeywords(decl.id.name, keywords)) ) { errors.add( 'You should use "' + keywords.join('" or "') + '" to save a reference to "this"', node.loc.start ); } } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (file.getNextToken(firstToken).value === '{') {··· return; } |
| ✓ Negative was executed (else) | }··· for (var i = 0; i < node.declarations.length; i++) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | ) {··· errors.add( 'You should use "' + keywords.join('" or "') + '" to save a reference to "this"', node.loc.start ); } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | (decl.init.type === 'ThisExpression' && checkKeywords(decl.id.name, keywords)) |
| ✓ Was returned | if (decl.init && |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | (decl.init.type === 'ThisExpression' && checkKeywords(decl.id.name, keywords)) |
| ✓ Was returned | (decl.init.type === 'ThisExpression' && checkKeywords(decl.id.name, keywords)) |
| Function (anonymous_1243) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('AssignmentExpression', function(node) {··· if ( // filter property assignments "foo.bar = this" node.left.type === 'Identifier' && (node.right.type === 'ThisExpression' && checkKeywords(node.left.name, keywords)) ) { errors.add( 'You should use "' + keywords.join('" or "') + '" to save a reference to "this"', node.loc.start ); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | ) {··· errors.add( 'You should use "' + keywords.join('" or "') + '" to save a reference to "this"', node.loc.start ); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | (node.right.type === 'ThisExpression' && checkKeywords(node.left.name, keywords)) |
| ✓ Was returned | node.left.type === 'Identifier' && |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | (node.right.type === 'ThisExpression' && checkKeywords(node.left.name, keywords)) |
| ✓ Was returned | (node.right.type === 'ThisExpression' && checkKeywords(node.left.name, keywords)) |
| Function checkKeywords | |
|---|---|
| ✓ Was called | function checkKeywords(name, keywords) {··· for (var i = 0; i < keywords.length; i++) { if (name === keywords[i]) { return false; } } return true; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (name === keywords[i]) {··· return false; } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_1245) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1246) | |
|---|---|
| ✓ Was called | configure: function(options) {··· var validProperties = [ 'lineBreakAfterOpeningBrace', 'lineBreakBeforeClosingBrace' ]; var optionName = this.getOptionName(); assert( typeof options === 'object' || options === true, optionName + ' option must be an object or boolean true' ); if (typeof options === 'object') { validProperties.forEach(function(key) { var isPresent = key in options; if (isPresent) { assert( options[key] === true, optionName + '.' + key + ' property requires true value or should be removed' ); } }); validProperties.forEach(function(property) { this['_' + property] = Boolean(options[property]); }.bind(this)); } }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | typeof options === 'object' || options === true, |
| ✓ Was returned | typeof options === 'object' || options === true, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof options === 'object') {··· validProperties.forEach(function(key) { var isPresent = key in options; if (isPresent) { assert( options[key] === true, optionName + '.' + key + ' property requires true value or should be removed' ); } }); validProperties.forEach(function(property) { this['_' + property] = Boolean(options[property]); }.bind(this)); } |
| ✓ Negative was executed (else) | }··· }, |
| Function (anonymous_1247) | |
|---|---|
| ✓ Was called | validProperties.forEach(function(key) {··· var isPresent = key in options; if (isPresent) { assert( options[key] === true, optionName + '.' + key + ' property requires true value or should be removed' ); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isPresent) {··· assert( options[key] === true, optionName + '.' + key + ' property requires true value or should be removed' ); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_1248) | |
|---|---|
| ✓ Was called | validProperties.forEach(function(property) {··· this['_' + property] = Boolean(options[property]); }.bind(this)); |
| Function (anonymous_1249) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'validateAlignedFunctionParameters'; }, |
| Function (anonymous_1250) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var lineBreakAfterOpeningBrace = this._lineBreakAfterOpeningBrace; var lineBreakBeforeClosingBrace = this._lineBreakBeforeClosingBrace; file.iterateNodesByType([ 'FunctionDeclaration', 'FunctionExpression', 'ArrowFunctionExpression' ], function(node) { // ignore this rule if there are no parameters if (node.params.length === 0) { return; } // ignore this rule if the parameters are not multi-line var firstParameter = file.getFirstNodeToken(node.params[0]); var lastParameter = node.params[node.params.length - 1]; if (firstParameter.loc.start.line === lastParameter.loc.end.line) { return; } // look for the furthest parameter start position var maxParamStartPos = 0; node.params.forEach(function(parameter) { maxParamStartPos = Math.max(maxParamStartPos, parameter.loc.start.column); }); // make sure all parameters are lined up node.params.forEach(function(parameter) { if (parameter.loc.start.column !== maxParamStartPos) { errors.add('Multi-line parameters are not aligned.', parameter.loc.start); } }); // make sure the first parameter is on a new line if (lineBreakAfterOpeningBrace) { var openingBrace = file.getPrevToken(firstParameter); errors.assert.differentLine({ token: openingBrace, nextToken: firstParameter, message: 'There is no line break after the opening brace' }); } // make sure the closing brace is on a new line if (lineBreakBeforeClosingBrace) { var bodyToken = file.getFirstNodeToken(node.body); var closingBrace = file.getPrevToken(bodyToken); errors.assert.differentLine({ token: lastParameter, nextToken: closingBrace, message: 'There is no line break before the closing brace' }); } }); } |
| Function (anonymous_1251) | |
|---|---|
| ✓ Was called | ], function(node) {··· // ignore this rule if there are no parameters if (node.params.length === 0) { return; } // ignore this rule if the parameters are not multi-line var firstParameter = file.getFirstNodeToken(node.params[0]); var lastParameter = node.params[node.params.length - 1]; if (firstParameter.loc.start.line === lastParameter.loc.end.line) { return; } // look for the furthest parameter start position var maxParamStartPos = 0; node.params.forEach(function(parameter) { maxParamStartPos = Math.max(maxParamStartPos, parameter.loc.start.column); }); // make sure all parameters are lined up node.params.forEach(function(parameter) { if (parameter.loc.start.column !== maxParamStartPos) { errors.add('Multi-line parameters are not aligned.', parameter.loc.start); } }); // make sure the first parameter is on a new line if (lineBreakAfterOpeningBrace) { var openingBrace = file.getPrevToken(firstParameter); errors.assert.differentLine({ token: openingBrace, nextToken: firstParameter, message: 'There is no line break after the opening brace' }); } // make sure the closing brace is on a new line if (lineBreakBeforeClosingBrace) { var bodyToken = file.getFirstNodeToken(node.body); var closingBrace = file.getPrevToken(bodyToken); errors.assert.differentLine({ token: lastParameter, nextToken: closingBrace, message: 'There is no line break before the closing brace' }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.params.length === 0) {··· return; } |
| ✓ Negative was executed (else) | }··· // ignore this rule if the parameters are not multi-line |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (firstParameter.loc.start.line === lastParameter.loc.end.line) {··· return; } |
| ✓ Negative was executed (else) | }··· // look for the furthest parameter start position |
| Function (anonymous_1252) | |
|---|---|
| ✓ Was called | node.params.forEach(function(parameter) {··· maxParamStartPos = Math.max(maxParamStartPos, parameter.loc.start.column); }); |
| Function (anonymous_1253) | |
|---|---|
| ✓ Was called | node.params.forEach(function(parameter) {··· if (parameter.loc.start.column !== maxParamStartPos) { errors.add('Multi-line parameters are not aligned.', parameter.loc.start); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (parameter.loc.start.column !== maxParamStartPos) {··· errors.add('Multi-line parameters are not aligned.', parameter.loc.start); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (lineBreakAfterOpeningBrace) {··· var openingBrace = file.getPrevToken(firstParameter); errors.assert.differentLine({ token: openingBrace, nextToken: firstParameter, message: 'There is no line break after the opening brace' }); } |
| ✓ Negative was executed (else) | }··· // make sure the closing brace is on a new line |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (lineBreakBeforeClosingBrace) {··· var bodyToken = file.getFirstNodeToken(node.body); var closingBrace = file.getPrevToken(bodyToken); errors.assert.differentLine({ token: lastParameter, nextToken: closingBrace, message: 'There is no line break before the closing brace' }); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_1254) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1255) | |
|---|---|
| ✓ Was called | configure: function(options) {··· var validPositions = { 'above': 'above', 'beside': 'beside' }; var allExcept = options.allExcept; assert( typeof options === 'object' && validPositions[options.position], this.getOptionName() + ' requires one of the following values: ' + Object.keys(validPositions).join(', ') ); if (Array.isArray(allExcept)) { assert( allExcept.every(function(el) { return typeof el === 'string'; }), 'Property `allExcept` in ' + allExcept + ' should be an array of strings' ); this._isExcepted = isPragma(allExcept); } else { this._isExcepted = isPragma(); } this._position = options.position; }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | typeof options === 'object' && validPositions[options.position], |
| ✓ Was returned | typeof options === 'object' && validPositions[options.position], |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (Array.isArray(allExcept)) {··· assert( allExcept.every(function(el) { return typeof el === 'string'; }), 'Property `allExcept` in ' + allExcept + ' should be an array of strings' ); this._isExcepted = isPragma(allExcept); } else { |
| ✓ Negative was executed (else) | } else {··· this._isExcepted = isPragma(); } |
| Function (anonymous_1256) | |
|---|---|
| ✓ Was called | allExcept.every(function(el) { return typeof el === 'string'; }), |
| Function (anonymous_1257) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'validateCommentPosition'; }, |
| Function (anonymous_1258) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var position = this._position; var isExcepted = this._isExcepted; file.iterateTokensByType('Line', function(comment) { if (isExcepted(comment.value)) { return; } var firstToken = file.getFirstTokenOnLine(comment.loc.start.line, { includeComments: true }); if (position === 'above' && !firstToken.isComment) { errors.add('Expected comments to be above the code not beside', comment.loc.start); } if (position === 'beside' && firstToken.isComment) { errors.add('Expected comments to be beside the code not above', comment.loc.start); } }); } |
| Function (anonymous_1259) | |
|---|---|
| ✓ Was called | file.iterateTokensByType('Line', function(comment) {··· if (isExcepted(comment.value)) { return; } var firstToken = file.getFirstTokenOnLine(comment.loc.start.line, { includeComments: true }); if (position === 'above' && !firstToken.isComment) { errors.add('Expected comments to be above the code not beside', comment.loc.start); } if (position === 'beside' && firstToken.isComment) { errors.add('Expected comments to be beside the code not above', comment.loc.start); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (isExcepted(comment.value)) {··· return; } |
| ✓ Negative was executed (else) | }··· var firstToken = file.getFirstTokenOnLine(comment.loc.start.line, { includeComments: true }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (position === 'above' && !firstToken.isComment) {··· errors.add('Expected comments to be above the code not beside', comment.loc.start); } |
| ✓ Negative was executed (else) | }··· if (position === 'beside' && firstToken.isComment) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (position === 'above' && !firstToken.isComment) { |
| ✓ Was returned | if (position === 'above' && !firstToken.isComment) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (position === 'beside' && firstToken.isComment) {··· errors.add('Expected comments to be beside the code not above', comment.loc.start); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch LogicalExpression | |
| ✓ Was returned | if (position === 'beside' && firstToken.isComment) { |
| ✓ Was returned | if (position === 'beside' && firstToken.isComment) { |
| Function (anonymous_1260) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1261) | |
|---|---|
| ✓ Was called | configure: function(options) {··· this._includeEmptyLines = false; this._exceptComments = false; if (typeof options === 'object') { this._includeEmptyLines = (options.includeEmptyLines === true); if (Array.isArray(options.allExcept)) { this._exceptComments = options.allExcept.indexOf('comments') > -1; this._includeEmptyLines = options.allExcept.indexOf('emptyLines') > -1; } options = options.value; } assert( options === '\t' || (typeof options === 'number' && options > 0), this.getOptionName() + ' option requires a positive number of spaces or "\\t"' + ' or options object with "value" property' ); if (typeof options === 'number') { this._indentChar = ' '; this._indentSize = options; } else { this._indentChar = '\t'; this._indentSize = 1; } this._breakIndents = null; this._moduleIndents = null; }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof options === 'object') {··· this._includeEmptyLines = (options.includeEmptyLines === true); if (Array.isArray(options.allExcept)) { this._exceptComments = options.allExcept.indexOf('comments') > -1; this._includeEmptyLines = options.allExcept.indexOf('emptyLines') > -1; } options = options.value; } |
| ✓ Negative was executed (else) | }··· assert( |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (Array.isArray(options.allExcept)) {··· this._exceptComments = options.allExcept.indexOf('comments') > -1; this._includeEmptyLines = options.allExcept.indexOf('emptyLines') > -1; } |
| ✓ Negative was executed (else) | }··· options = options.value; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | (typeof options === 'number' && options > 0), |
| ✓ Was returned | options === '\t' || |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | (typeof options === 'number' && options > 0), |
| ✓ Was returned | (typeof options === 'number' && options > 0), |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof options === 'number') {··· this._indentChar = ' '; this._indentSize = options; } else { |
| ✓ Negative was executed (else) | } else {··· this._indentChar = '\t'; this._indentSize = 1; } |
| Function (anonymous_1262) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'validateIndentation'; }, |
| Function (anonymous_1263) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· function markCheckLine(line) { linesToCheck[line].check = true; } function markCheck(node) { markCheckLine(node.loc.start.line - 1); } function markEndCheck(node) { markCheckLine(node.loc.end.line - 1); } function markPush(node, indents) { linesToCheck[node.loc.start.line - 1].push.push(indents); } function markPop(node, outdents) { linesToCheck[node.loc.end.line - 1].pop.push(outdents); } function markPushAlt(node) { linesToCheck[node.loc.start.line - 1].pushAltLine.push(node.loc.end.line - 1); } function markCase(caseNode, children) { var outdentNode = getCaseOutdent(children); if (outdentNode) { // If a case statement has a `break` as a direct child and it is the // first one encountered, use it as the example for all future case indentation if (_this._breakIndents === null) { _this._breakIndents = (caseNode.loc.start.column === outdentNode.loc.start.column) ? 1 : 0; } markPop(outdentNode, _this._breakIndents); } else { markPop(caseNode, 0); } } function markChildren(node) { getChildren(node).forEach(function(childNode) { if (childNode.loc.start.line !== node.loc.start.line) { markCheck(childNode); } }); } function markKeyword(node) { if (node) { markCheck(file.getPrevToken(file.getFirstNodeToken(node))); } } function isMultiline(node) { return node.loc.start.line !== node.loc.end.line; } function getCaseOutdent(caseChildren) { var outdentNode; caseChildren.some(function(node) { if (node.type === 'BreakStatement') { outdentNode = node; return true; } }); return outdentNode; } function getBlockNodeToPush(node) { var parent = node.parentNode; // The parent of an else is the entire if/else block. To avoid over indenting // in the case of a non-block if with a block else, mark push where the else starts, // not where the if starts! if (parent.type === 'IfStatement' && parent.alternate === node) { return node; } // The end line to check of a do while statement needs to be the location of the // closing curly brace, not the while statement, to avoid marking the last line of // a multiline while as a line to check. if (parent.type === 'DoWhileStatement') { return node; } // Detect bare blocks: a block whose parent doesn't expect blocks in its syntax specifically. if (blockParents.indexOf(parent.type) === -1) { return node; } return parent; } function getChildren(node) { var childrenProperty = indentableNodes[node.type]; return node[childrenProperty]; } function getIndentationFromLine(line) { var firstContent = line.search(rNotIndentChar); if (firstContent === -1) { firstContent = line.length; } return firstContent; } function checkIndentations() { var lineAugment = 0; linesToCheck.forEach(function(line, i) { var lineNumber = i + 1; var actualIndentation = line.indentation; var expectedIndentation = getExpectedIndentation(line, actualIndentation); // do not augment this line considering this line changes indentation if (line.pop.length || line.push.length) { lineAugment = 0; } if (line.check) { errors.assert.indentation({ lineNumber: lineNumber, actual: actualIndentation, expected: expectedIndentation, indentChar: indentChar }); // for multiline statements, we need move subsequent lines over the correct // number of spaces to match the change made to the first line of the statement. lineAugment = expectedIndentation - actualIndentation; // correct the indentation so that future lines can be validated appropriately actualIndentation = expectedIndentation; } else if (!line.empty) { // in the case that we moved a previous line over a certain number spaces, // we need to move this line over as well, but technically, it's not an error errors.assert.indentation({ lineNumber: lineNumber, actual: actualIndentation, // Avoid going negative in the case that a previous line was overindented, // and now outdenting a line that is already at column zero. expected: Math.max(actualIndentation + lineAugment, 0), indentChar: indentChar, silent: true }); } if (line.push.length) { pushExpectedIndentations(line, actualIndentation); } }); } function getExpectedIndentation(line, actual) { var outdent = indentSize * Math.max.apply(null, line.pop); var idx = indentStack.length - 1; var expected = indentStack[idx]; if (!Array.isArray(expected)) { expected = [expected]; } expected = expected.map(function(value) { if (line.pop.length) { value -= outdent; } return value; }).reduce(function(previous, current) { // when the expected is an array, resolve the value // back into a Number by checking both values are the actual indentation return actual === current ? current : previous; }); indentStack[idx] = expected; line.pop.forEach(function() { indentStack.pop(); }); return expected; } function pushExpectedIndentations(line, actualIndentation) { var indents = Math.max.apply(null, line.push); var expected = actualIndentation + (indentSize * indents); // when a line has alternate indentations, push an array of possible values // on the stack, to be resolved when checked against an actual indentation if (line.pushAltLine.length) { expected = [expected]; line.pushAltLine.forEach(function(altLine) { expected.push(linesToCheck[altLine].indentation + (indentSize * indents)); }); } line.push.forEach(function() { indentStack.push(expected); }); } function setModuleBody(node) { if (node.body.length !== 1 || node.body[0].type !== 'ExpressionStatement' || node.body[0].expression.type !== 'CallExpression') { return; } var callExpression = node.body[0].expression; var callee = callExpression.callee; var callArgs = callExpression.arguments; var iffeFunction = utils.getFunctionNodeFromIIFE(callExpression); if (iffeFunction) { if (callArgs.length === 1 && callArgs[0].type === 'FunctionExpression') { // detect UMD Shim, where the file body is the body of the factory, // which is the sole argument to the IIFE moduleBody = callArgs[0].body; } else { // full file IIFE moduleBody = iffeFunction.body; } } // detect require/define if (callee.type === 'Identifier' && callee.name.match(/^(require|define)$/)) { // the define callback is the *first* functionExpression encountered, // as it can be the first, second, or third argument. callArgs.some(function(argument) { if (argument.type === 'FunctionExpression') { moduleBody = argument.body; return true; } }); } // set number of indents for modules by detecting // whether the first statement is indented or not if (moduleBody && moduleBody.body.length) { _this._moduleIndents = moduleBody.body[0].loc.start.column > 0 ? 1 : 0; } } function generateIndentations() { file.iterateNodesByType('Program', function(node) { if (!isMultiline(node)) { return; } setModuleBody(node); markChildren(node); }); file.iterateNodesByType('BlockStatement', function(node) { if (!isMultiline(node)) { return; } var indents = node === moduleBody ? _this._moduleIndents : 1; markChildren(node); markPop(node, indents); markPush(getBlockNodeToPush(node), indents); markEndCheck(node); }); file.iterateNodesByType('ObjectExpression', function(node) { if (!isMultiline(node)) { return; } var children = getChildren(node); // only check objects that have children and that look like they are trying to adhere // to an indentation strategy, i.e. objects that have curly braces on their own lines. if (!children.length || node.loc.start.line === children[0].loc.start.line || node.loc.end.line === children[children.length - 1].loc.end.line) { return; } markChildren(node); markPop(node, 1); markPush(node, 1); markEndCheck(node); markPushAlt(node); }); file.iterateNodesByType('IfStatement', function(node) { markKeyword(node.alternate); }); file.iterateNodesByType('TryStatement', function(node) { if (!isMultiline(node)) { return; } var handler = node.handlers && node.handlers.length ? node.handlers[0] : node.handler; if (handler) { markCheck(handler); } markKeyword(node.finalizer); }); file.iterateNodesByType('SwitchStatement', function(node) { if (!isMultiline(node)) { return; } var indents = 1; var children = getChildren(node); if (children.length < 1) { return; } if (node.loc.start.column === children[0].loc.start.column) { indents = 0; } markChildren(node); markPop(node, indents); markPush(node, indents); markEndCheck(node); }); file.iterateNodesByType('SwitchCase', function(node) { if (!isMultiline(node)) { return; } var children = getChildren(node); if (children.length === 1 && children[0].type === 'BlockStatement') { return; } markPush(node, 1); markCheck(node); markChildren(node); markCase(node, children); }); // indentations inside of function expressions can be offset from // either the start of the function or the end of the function, therefore // mark all starting lines of functions as potential indentations file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) { markPushAlt(node); }); if (_this._includeEmptyLines) { linesToCheck.forEach(function(line) { if (line.empty) { line.check = true; } }); } if (!_this._exceptComments) { // starting from the bottom, which allows back to back comments to be checked, mark comments file.getComments().concat().reverse().forEach(function(node) { var startLine = node.loc.start.line; var firstToken = file.getFirstTokenOnLine(startLine, { includeComments: true }); var nextToken = file.getNextToken(firstToken, { includeComments: true }); var nextStartLine = nextToken.loc.start.line; var nextLine = linesToCheck[nextStartLine - 1]; // ignore if not the only token on the line, or not right above another checked line if (firstToken !== node || startLine === nextStartLine || !nextLine.check) { return; } // ignore if next line is a case statement, which is kind of hacky, but avoids // additional complexity for what qualifies as an outdent if (nextToken && nextToken.type === 'Keyword' && (nextToken.value === 'case' || nextToken.value === 'default')) { return; } // ignore if above a line that both introduces and ends an ident, // which catches cases like a comment above an `else if`, but not nested ifs. if (nextLine.push.length && nextLine.pop.length) { return; } markCheck(node); }); } } var _this = this; var moduleBody; var indentChar = this._indentChar; var indentSize = this._indentSize; var rNotIndentChar = new RegExp('[^' + indentChar + ']'); var indentStack = [0]; var linesToCheck = file.getLines().map(function(line) { return { push: [], pushAltLine: [], pop: [], check: false, indentation: getIndentationFromLine(line), empty: line.match(/^\s*$/) }; }); generateIndentations(); checkIndentations(); } |
| Function markCheckLine | |
|---|---|
| ✓ Was called | function markCheckLine(line) {··· linesToCheck[line].check = true; } |
| Function markCheck | |
|---|---|
| ✓ Was called | function markCheck(node) {··· markCheckLine(node.loc.start.line - 1); } |
| Function markEndCheck | |
|---|---|
| ✓ Was called | function markEndCheck(node) {··· markCheckLine(node.loc.end.line - 1); } |
| Function markPush | |
|---|---|
| ✓ Was called | function markPush(node, indents) {··· linesToCheck[node.loc.start.line - 1].push.push(indents); } |
| Function markPop | |
|---|---|
| ✓ Was called | function markPop(node, outdents) {··· linesToCheck[node.loc.end.line - 1].pop.push(outdents); } |
| Function markPushAlt | |
|---|---|
| ✓ Was called | function markPushAlt(node) {··· linesToCheck[node.loc.start.line - 1].pushAltLine.push(node.loc.end.line - 1); } |
| Function markCase | |
|---|---|
| ✓ Was called | function markCase(caseNode, children) {··· var outdentNode = getCaseOutdent(children); if (outdentNode) { // If a case statement has a `break` as a direct child and it is the // first one encountered, use it as the example for all future case indentation if (_this._breakIndents === null) { _this._breakIndents = (caseNode.loc.start.column === outdentNode.loc.start.column) ? 1 : 0; } markPop(outdentNode, _this._breakIndents); } else { markPop(caseNode, 0); } } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (outdentNode) {··· // If a case statement has a `break` as a direct child and it is the // first one encountered, use it as the example for all future case indentation if (_this._breakIndents === null) { _this._breakIndents = (caseNode.loc.start.column === outdentNode.loc.start.column) ? 1 : 0; } markPop(outdentNode, _this._breakIndents); } else { |
| ✓ Negative was executed (else) | } else {··· markPop(caseNode, 0); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (_this._breakIndents === null) {··· _this._breakIndents = (caseNode.loc.start.column === outdentNode.loc.start.column) ? 1 : 0; } |
| ✓ Negative was executed (else) | }··· markPop(outdentNode, _this._breakIndents); |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | _this._breakIndents = (caseNode.loc.start.column === outdentNode.loc.start.column) ? 1 : 0; |
| ✓ Negative was returned (: ...) | _this._breakIndents = (caseNode.loc.start.column === outdentNode.loc.start.column) ? 1 : 0; |
| Function markChildren | |
|---|---|
| ✓ Was called | function markChildren(node) {··· getChildren(node).forEach(function(childNode) { if (childNode.loc.start.line !== node.loc.start.line) { markCheck(childNode); } }); } |
| Function (anonymous_1272) | |
|---|---|
| ✓ Was called | getChildren(node).forEach(function(childNode) {··· if (childNode.loc.start.line !== node.loc.start.line) { markCheck(childNode); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (childNode.loc.start.line !== node.loc.start.line) {··· markCheck(childNode); } |
| ✓ Negative was executed (else) | }··· }); |
| Function markKeyword | |
|---|---|
| ✓ Was called | function markKeyword(node) {··· if (node) { markCheck(file.getPrevToken(file.getFirstNodeToken(node))); } } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node) {··· markCheck(file.getPrevToken(file.getFirstNodeToken(node))); } |
| ✓ Negative was executed (else) | }··· } |
| Function isMultiline | |
|---|---|
| ✓ Was called | function isMultiline(node) {··· return node.loc.start.line !== node.loc.end.line; } |
| Function getCaseOutdent | |
|---|---|
| ✓ Was called | function getCaseOutdent(caseChildren) {··· var outdentNode; caseChildren.some(function(node) { if (node.type === 'BreakStatement') { outdentNode = node; return true; } }); return outdentNode; } |
| Function (anonymous_1276) | |
|---|---|
| ✓ Was called | caseChildren.some(function(node) {··· if (node.type === 'BreakStatement') { outdentNode = node; return true; } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.type === 'BreakStatement') {··· outdentNode = node; return true; } |
| ✓ Negative was executed (else) | }··· }); |
| Function getBlockNodeToPush | |
|---|---|
| ✓ Was called | function getBlockNodeToPush(node) {··· var parent = node.parentNode; // The parent of an else is the entire if/else block. To avoid over indenting // in the case of a non-block if with a block else, mark push where the else starts, // not where the if starts! if (parent.type === 'IfStatement' && parent.alternate === node) { return node; } // The end line to check of a do while statement needs to be the location of the // closing curly brace, not the while statement, to avoid marking the last line of // a multiline while as a line to check. if (parent.type === 'DoWhileStatement') { return node; } // Detect bare blocks: a block whose parent doesn't expect blocks in its syntax specifically. if (blockParents.indexOf(parent.type) === -1) { return node; } return parent; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (parent.type === 'IfStatement' && parent.alternate === node) {··· return node; } |
| ✓ Negative was executed (else) | }··· // The end line to check of a do while statement needs to be the location of the |
| Branch LogicalExpression | |
| ✓ Was returned | if (parent.type === 'IfStatement' && parent.alternate === node) { |
| ✓ Was returned | if (parent.type === 'IfStatement' && parent.alternate === node) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (parent.type === 'DoWhileStatement') {··· return node; } |
| ✓ Negative was executed (else) | }··· // Detect bare blocks: a block whose parent doesn't expect blocks in its syntax specifically. |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (blockParents.indexOf(parent.type) === -1) {··· return node; } |
| ✓ Negative was executed (else) | }··· return parent; |
| Function getChildren | |
|---|---|
| ✓ Was called | function getChildren(node) {··· var childrenProperty = indentableNodes[node.type]; return node[childrenProperty]; } |
| Function getIndentationFromLine | |
|---|---|
| ✓ Was called | function getIndentationFromLine(line) {··· var firstContent = line.search(rNotIndentChar); if (firstContent === -1) { firstContent = line.length; } return firstContent; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (firstContent === -1) {··· firstContent = line.length; } |
| ✓ Negative was executed (else) | }··· return firstContent; |
| Function checkIndentations | |
|---|---|
| ✓ Was called | function checkIndentations() {··· var lineAugment = 0; linesToCheck.forEach(function(line, i) { var lineNumber = i + 1; var actualIndentation = line.indentation; var expectedIndentation = getExpectedIndentation(line, actualIndentation); // do not augment this line considering this line changes indentation if (line.pop.length || line.push.length) { lineAugment = 0; } if (line.check) { errors.assert.indentation({ lineNumber: lineNumber, actual: actualIndentation, expected: expectedIndentation, indentChar: indentChar }); // for multiline statements, we need move subsequent lines over the correct // number of spaces to match the change made to the first line of the statement. lineAugment = expectedIndentation - actualIndentation; // correct the indentation so that future lines can be validated appropriately actualIndentation = expectedIndentation; } else if (!line.empty) { // in the case that we moved a previous line over a certain number spaces, // we need to move this line over as well, but technically, it's not an error errors.assert.indentation({ lineNumber: lineNumber, actual: actualIndentation, // Avoid going negative in the case that a previous line was overindented, // and now outdenting a line that is already at column zero. expected: Math.max(actualIndentation + lineAugment, 0), indentChar: indentChar, silent: true }); } if (line.push.length) { pushExpectedIndentations(line, actualIndentation); } }); } |
| Function (anonymous_1281) | |
|---|---|
| ✓ Was called | linesToCheck.forEach(function(line, i) {··· var lineNumber = i + 1; var actualIndentation = line.indentation; var expectedIndentation = getExpectedIndentation(line, actualIndentation); // do not augment this line considering this line changes indentation if (line.pop.length || line.push.length) { lineAugment = 0; } if (line.check) { errors.assert.indentation({ lineNumber: lineNumber, actual: actualIndentation, expected: expectedIndentation, indentChar: indentChar }); // for multiline statements, we need move subsequent lines over the correct // number of spaces to match the change made to the first line of the statement. lineAugment = expectedIndentation - actualIndentation; // correct the indentation so that future lines can be validated appropriately actualIndentation = expectedIndentation; } else if (!line.empty) { // in the case that we moved a previous line over a certain number spaces, // we need to move this line over as well, but technically, it's not an error errors.assert.indentation({ lineNumber: lineNumber, actual: actualIndentation, // Avoid going negative in the case that a previous line was overindented, // and now outdenting a line that is already at column zero. expected: Math.max(actualIndentation + lineAugment, 0), indentChar: indentChar, silent: true }); } if (line.push.length) { pushExpectedIndentations(line, actualIndentation); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (line.pop.length || line.push.length) {··· lineAugment = 0; } |
| ✓ Negative was executed (else) | }··· if (line.check) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (line.pop.length || line.push.length) { |
| ✓ Was returned | if (line.pop.length || line.push.length) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (line.check) {··· errors.assert.indentation({ lineNumber: lineNumber, actual: actualIndentation, expected: expectedIndentation, indentChar: indentChar }); // for multiline statements, we need move subsequent lines over the correct // number of spaces to match the change made to the first line of the statement. lineAugment = expectedIndentation - actualIndentation; // correct the indentation so that future lines can be validated appropriately actualIndentation = expectedIndentation; } else if (!line.empty) { |
| ✓ Negative was executed (else) | } else if (!line.empty) {··· // in the case that we moved a previous line over a certain number spaces, // we need to move this line over as well, but technically, it's not an error errors.assert.indentation({ lineNumber: lineNumber, actual: actualIndentation, // Avoid going negative in the case that a previous line was overindented, // and now outdenting a line that is already at column zero. expected: Math.max(actualIndentation + lineAugment, 0), indentChar: indentChar, silent: true }); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | } else if (!line.empty) {··· // in the case that we moved a previous line over a certain number spaces, // we need to move this line over as well, but technically, it's not an error errors.assert.indentation({ lineNumber: lineNumber, actual: actualIndentation, // Avoid going negative in the case that a previous line was overindented, // and now outdenting a line that is already at column zero. expected: Math.max(actualIndentation + lineAugment, 0), indentChar: indentChar, silent: true }); } |
| ✓ Negative was executed (else) | }··· if (line.push.length) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (line.push.length) {··· pushExpectedIndentations(line, actualIndentation); } |
| ✓ Negative was executed (else) | }··· }); |
| Function getExpectedIndentation | |
|---|---|
| ✓ Was called | function getExpectedIndentation(line, actual) {··· var outdent = indentSize * Math.max.apply(null, line.pop); var idx = indentStack.length - 1; var expected = indentStack[idx]; if (!Array.isArray(expected)) { expected = [expected]; } expected = expected.map(function(value) { if (line.pop.length) { value -= outdent; } return value; }).reduce(function(previous, current) { // when the expected is an array, resolve the value // back into a Number by checking both values are the actual indentation return actual === current ? current : previous; }); indentStack[idx] = expected; line.pop.forEach(function() { indentStack.pop(); }); return expected; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!Array.isArray(expected)) {··· expected = [expected]; } |
| ✓ Negative was executed (else) | }··· expected = expected.map(function(value) { |
| Function (anonymous_1283) | |
|---|---|
| ✓ Was called | expected = expected.map(function(value) {··· if (line.pop.length) { value -= outdent; } return value; }).reduce(function(previous, current) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (line.pop.length) {··· value -= outdent; } |
| ✓ Negative was executed (else) | }··· return value; |
| Function (anonymous_1284) | |
|---|---|
| ✓ Was called | }).reduce(function(previous, current) {··· // when the expected is an array, resolve the value // back into a Number by checking both values are the actual indentation return actual === current ? current : previous; }); |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | return actual === current ? current : previous; |
| ✓ Negative was returned (: ...) | return actual === current ? current : previous; |
| Function (anonymous_1285) | |
|---|---|
| ✓ Was called | line.pop.forEach(function() {··· indentStack.pop(); }); |
| Function pushExpectedIndentations | |
|---|---|
| ✓ Was called | function pushExpectedIndentations(line, actualIndentation) {··· var indents = Math.max.apply(null, line.push); var expected = actualIndentation + (indentSize * indents); // when a line has alternate indentations, push an array of possible values // on the stack, to be resolved when checked against an actual indentation if (line.pushAltLine.length) { expected = [expected]; line.pushAltLine.forEach(function(altLine) { expected.push(linesToCheck[altLine].indentation + (indentSize * indents)); }); } line.push.forEach(function() { indentStack.push(expected); }); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (line.pushAltLine.length) {··· expected = [expected]; line.pushAltLine.forEach(function(altLine) { expected.push(linesToCheck[altLine].indentation + (indentSize * indents)); }); } |
| ✓ Negative was executed (else) | }··· line.push.forEach(function() { |
| Function (anonymous_1287) | |
|---|---|
| ✓ Was called | line.pushAltLine.forEach(function(altLine) {··· expected.push(linesToCheck[altLine].indentation + (indentSize * indents)); }); |
| Function (anonymous_1288) | |
|---|---|
| ✓ Was called | line.push.forEach(function() {··· indentStack.push(expected); }); |
| Function setModuleBody | |
|---|---|
| ✓ Was called | function setModuleBody(node) {··· if (node.body.length !== 1 || node.body[0].type !== 'ExpressionStatement' || node.body[0].expression.type !== 'CallExpression') { return; } var callExpression = node.body[0].expression; var callee = callExpression.callee; var callArgs = callExpression.arguments; var iffeFunction = utils.getFunctionNodeFromIIFE(callExpression); if (iffeFunction) { if (callArgs.length === 1 && callArgs[0].type === 'FunctionExpression') { // detect UMD Shim, where the file body is the body of the factory, // which is the sole argument to the IIFE moduleBody = callArgs[0].body; } else { // full file IIFE moduleBody = iffeFunction.body; } } // detect require/define if (callee.type === 'Identifier' && callee.name.match(/^(require|define)$/)) { // the define callback is the *first* functionExpression encountered, // as it can be the first, second, or third argument. callArgs.some(function(argument) { if (argument.type === 'FunctionExpression') { moduleBody = argument.body; return true; } }); } // set number of indents for modules by detecting // whether the first statement is indented or not if (moduleBody && moduleBody.body.length) { _this._moduleIndents = moduleBody.body[0].loc.start.column > 0 ? 1 : 0; } } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | node.body[0].expression.type !== 'CallExpression') {··· return; } |
| ✓ Negative was executed (else) | }··· var callExpression = node.body[0].expression; |
| Branch LogicalExpression | |
| ✓ Was returned | node.body[0].expression.type !== 'CallExpression') { |
| ✓ Was returned | if (node.body.length !== 1 || node.body[0].type !== 'ExpressionStatement' || |
| Branch LogicalExpression | |
| ✓ Was returned | if (node.body.length !== 1 || node.body[0].type !== 'ExpressionStatement' || |
| ✓ Was returned | if (node.body.length !== 1 || node.body[0].type !== 'ExpressionStatement' || |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (iffeFunction) {··· if (callArgs.length === 1 && callArgs[0].type === 'FunctionExpression') { // detect UMD Shim, where the file body is the body of the factory, // which is the sole argument to the IIFE moduleBody = callArgs[0].body; } else { // full file IIFE moduleBody = iffeFunction.body; } } |
| ✓ Negative was executed (else) | }··· // detect require/define |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (callArgs.length === 1 && callArgs[0].type === 'FunctionExpression') {··· // detect UMD Shim, where the file body is the body of the factory, // which is the sole argument to the IIFE moduleBody = callArgs[0].body; } else { |
| ✓ Negative was executed (else) | } else {··· // full file IIFE moduleBody = iffeFunction.body; } |
| Branch LogicalExpression | |
| ✓ Was returned | if (callArgs.length === 1 && callArgs[0].type === 'FunctionExpression') { |
| ✗ Was not returned | if (callArgs.length === 1 && callArgs[0].type === 'FunctionExpression') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (callee.type === 'Identifier' && callee.name.match(/^(require|define)$/)) {··· // the define callback is the *first* functionExpression encountered, // as it can be the first, second, or third argument. callArgs.some(function(argument) { if (argument.type === 'FunctionExpression') { moduleBody = argument.body; return true; } }); } |
| ✓ Negative was executed (else) | }··· // set number of indents for modules by detecting |
| Branch LogicalExpression | |
| ✓ Was returned | if (callee.type === 'Identifier' && callee.name.match(/^(require|define)$/)) { |
| ✓ Was returned | if (callee.type === 'Identifier' && callee.name.match(/^(require|define)$/)) { |
| Function (anonymous_1290) | |
|---|---|
| ✓ Was called | callArgs.some(function(argument) {··· if (argument.type === 'FunctionExpression') { moduleBody = argument.body; return true; } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (argument.type === 'FunctionExpression') {··· moduleBody = argument.body; return true; } |
| ✓ Negative was executed (else) | }··· }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (moduleBody && moduleBody.body.length) {··· _this._moduleIndents = moduleBody.body[0].loc.start.column > 0 ? 1 : 0; } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | if (moduleBody && moduleBody.body.length) { |
| ✓ Was returned | if (moduleBody && moduleBody.body.length) { |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | _this._moduleIndents = moduleBody.body[0].loc.start.column > 0 ? 1 : 0; |
| ✓ Negative was returned (: ...) | _this._moduleIndents = moduleBody.body[0].loc.start.column > 0 ? 1 : 0; |
| Function generateIndentations | |
|---|---|
| ✓ Was called | function generateIndentations() {··· file.iterateNodesByType('Program', function(node) { if (!isMultiline(node)) { return; } setModuleBody(node); markChildren(node); }); file.iterateNodesByType('BlockStatement', function(node) { if (!isMultiline(node)) { return; } var indents = node === moduleBody ? _this._moduleIndents : 1; markChildren(node); markPop(node, indents); markPush(getBlockNodeToPush(node), indents); markEndCheck(node); }); file.iterateNodesByType('ObjectExpression', function(node) { if (!isMultiline(node)) { return; } var children = getChildren(node); // only check objects that have children and that look like they are trying to adhere // to an indentation strategy, i.e. objects that have curly braces on their own lines. if (!children.length || node.loc.start.line === children[0].loc.start.line || node.loc.end.line === children[children.length - 1].loc.end.line) { return; } markChildren(node); markPop(node, 1); markPush(node, 1); markEndCheck(node); markPushAlt(node); }); file.iterateNodesByType('IfStatement', function(node) { markKeyword(node.alternate); }); file.iterateNodesByType('TryStatement', function(node) { if (!isMultiline(node)) { return; } var handler = node.handlers && node.handlers.length ? node.handlers[0] : node.handler; if (handler) { markCheck(handler); } markKeyword(node.finalizer); }); file.iterateNodesByType('SwitchStatement', function(node) { if (!isMultiline(node)) { return; } var indents = 1; var children = getChildren(node); if (children.length < 1) { return; } if (node.loc.start.column === children[0].loc.start.column) { indents = 0; } markChildren(node); markPop(node, indents); markPush(node, indents); markEndCheck(node); }); file.iterateNodesByType('SwitchCase', function(node) { if (!isMultiline(node)) { return; } var children = getChildren(node); if (children.length === 1 && children[0].type === 'BlockStatement') { return; } markPush(node, 1); markCheck(node); markChildren(node); markCase(node, children); }); // indentations inside of function expressions can be offset from // either the start of the function or the end of the function, therefore // mark all starting lines of functions as potential indentations file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) { markPushAlt(node); }); if (_this._includeEmptyLines) { linesToCheck.forEach(function(line) { if (line.empty) { line.check = true; } }); } if (!_this._exceptComments) { // starting from the bottom, which allows back to back comments to be checked, mark comments file.getComments().concat().reverse().forEach(function(node) { var startLine = node.loc.start.line; var firstToken = file.getFirstTokenOnLine(startLine, { includeComments: true }); var nextToken = file.getNextToken(firstToken, { includeComments: true }); var nextStartLine = nextToken.loc.start.line; var nextLine = linesToCheck[nextStartLine - 1]; // ignore if not the only token on the line, or not right above another checked line if (firstToken !== node || startLine === nextStartLine || !nextLine.check) { return; } // ignore if next line is a case statement, which is kind of hacky, but avoids // additional complexity for what qualifies as an outdent if (nextToken && nextToken.type === 'Keyword' && (nextToken.value === 'case' || nextToken.value === 'default')) { return; } // ignore if above a line that both introduces and ends an ident, // which catches cases like a comment above an `else if`, but not nested ifs. if (nextLine.push.length && nextLine.pop.length) { return; } markCheck(node); }); } } |
| Function (anonymous_1292) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('Program', function(node) {··· if (!isMultiline(node)) { return; } setModuleBody(node); markChildren(node); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!isMultiline(node)) {··· return; } |
| ✓ Negative was executed (else) | }··· setModuleBody(node); |
| Function (anonymous_1293) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('BlockStatement', function(node) {··· if (!isMultiline(node)) { return; } var indents = node === moduleBody ? _this._moduleIndents : 1; markChildren(node); markPop(node, indents); markPush(getBlockNodeToPush(node), indents); markEndCheck(node); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!isMultiline(node)) {··· return; } |
| ✓ Negative was executed (else) | }··· var indents = node === moduleBody ? _this._moduleIndents : 1; |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | var indents = node === moduleBody ? _this._moduleIndents : 1; |
| ✓ Negative was returned (: ...) | var indents = node === moduleBody ? _this._moduleIndents : 1; |
| Function (anonymous_1294) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('ObjectExpression', function(node) {··· if (!isMultiline(node)) { return; } var children = getChildren(node); // only check objects that have children and that look like they are trying to adhere // to an indentation strategy, i.e. objects that have curly braces on their own lines. if (!children.length || node.loc.start.line === children[0].loc.start.line || node.loc.end.line === children[children.length - 1].loc.end.line) { return; } markChildren(node); markPop(node, 1); markPush(node, 1); markEndCheck(node); markPushAlt(node); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!isMultiline(node)) {··· return; } |
| ✓ Negative was executed (else) | }··· var children = getChildren(node); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | node.loc.end.line === children[children.length - 1].loc.end.line) {··· return; } |
| ✓ Negative was executed (else) | }··· markChildren(node); |
| Branch LogicalExpression | |
| ✓ Was returned | node.loc.end.line === children[children.length - 1].loc.end.line) { |
| ✓ Was returned | if (!children.length || node.loc.start.line === children[0].loc.start.line || |
| Branch LogicalExpression | |
| ✓ Was returned | if (!children.length || node.loc.start.line === children[0].loc.start.line || |
| ✗ Was not returned | if (!children.length || node.loc.start.line === children[0].loc.start.line || |
| Function (anonymous_1295) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('IfStatement', function(node) {··· markKeyword(node.alternate); }); |
| Function (anonymous_1296) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('TryStatement', function(node) {··· if (!isMultiline(node)) { return; } var handler = node.handlers && node.handlers.length ? node.handlers[0] : node.handler; if (handler) { markCheck(handler); } markKeyword(node.finalizer); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!isMultiline(node)) {··· return; } |
| ✓ Negative was executed (else) | }··· var handler = node.handlers && node.handlers.length ? node.handlers[0] : node.handler; |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | var handler = node.handlers && node.handlers.length ? node.handlers[0] : node.handler; |
| ✓ Negative was returned (: ...) | var handler = node.handlers && node.handlers.length ? node.handlers[0] : node.handler; |
| Branch LogicalExpression | |
| ✓ Was returned | var handler = node.handlers && node.handlers.length ? node.handlers[0] : node.handler; |
| ✗ Was not returned | var handler = node.handlers && node.handlers.length ? node.handlers[0] : node.handler; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (handler) {··· markCheck(handler); } |
| ✓ Negative was executed (else) | }··· markKeyword(node.finalizer); |
| Function (anonymous_1297) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('SwitchStatement', function(node) {··· if (!isMultiline(node)) { return; } var indents = 1; var children = getChildren(node); if (children.length < 1) { return; } if (node.loc.start.column === children[0].loc.start.column) { indents = 0; } markChildren(node); markPop(node, indents); markPush(node, indents); markEndCheck(node); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!isMultiline(node)) {··· return; } |
| ✓ Negative was executed (else) | }··· var indents = 1; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (children.length < 1) {··· return; } |
| ✓ Negative was executed (else) | }··· if (node.loc.start.column === children[0].loc.start.column) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node.loc.start.column === children[0].loc.start.column) {··· indents = 0; } |
| ✓ Negative was executed (else) | }··· markChildren(node); |
| Function (anonymous_1298) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('SwitchCase', function(node) {··· if (!isMultiline(node)) { return; } var children = getChildren(node); if (children.length === 1 && children[0].type === 'BlockStatement') { return; } markPush(node, 1); markCheck(node); markChildren(node); markCase(node, children); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!isMultiline(node)) {··· return; } |
| ✓ Negative was executed (else) | }··· var children = getChildren(node); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (children.length === 1 && children[0].type === 'BlockStatement') {··· return; } |
| ✓ Negative was executed (else) | }··· markPush(node, 1); |
| Branch LogicalExpression | |
| ✓ Was returned | if (children.length === 1 && children[0].type === 'BlockStatement') { |
| ✓ Was returned | if (children.length === 1 && children[0].type === 'BlockStatement') { |
| Function (anonymous_1299) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) {··· markPushAlt(node); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (_this._includeEmptyLines) {··· linesToCheck.forEach(function(line) { if (line.empty) { line.check = true; } }); } |
| ✓ Negative was executed (else) | }··· if (!_this._exceptComments) { |
| Function (anonymous_1300) | |
|---|---|
| ✓ Was called | linesToCheck.forEach(function(line) {··· if (line.empty) { line.check = true; } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (line.empty) {··· line.check = true; } |
| ✓ Negative was executed (else) | }··· }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!_this._exceptComments) {··· // starting from the bottom, which allows back to back comments to be checked, mark comments file.getComments().concat().reverse().forEach(function(node) { var startLine = node.loc.start.line; var firstToken = file.getFirstTokenOnLine(startLine, { includeComments: true }); var nextToken = file.getNextToken(firstToken, { includeComments: true }); var nextStartLine = nextToken.loc.start.line; var nextLine = linesToCheck[nextStartLine - 1]; // ignore if not the only token on the line, or not right above another checked line if (firstToken !== node || startLine === nextStartLine || !nextLine.check) { return; } // ignore if next line is a case statement, which is kind of hacky, but avoids // additional complexity for what qualifies as an outdent if (nextToken && nextToken.type === 'Keyword' && (nextToken.value === 'case' || nextToken.value === 'default')) { return; } // ignore if above a line that both introduces and ends an ident, // which catches cases like a comment above an `else if`, but not nested ifs. if (nextLine.push.length && nextLine.pop.length) { return; } markCheck(node); }); } |
| ✓ Negative was executed (else) | }··· } |
| Function (anonymous_1301) | |
|---|---|
| ✓ Was called | file.getComments().concat().reverse().forEach(function(node) {··· var startLine = node.loc.start.line; var firstToken = file.getFirstTokenOnLine(startLine, { includeComments: true }); var nextToken = file.getNextToken(firstToken, { includeComments: true }); var nextStartLine = nextToken.loc.start.line; var nextLine = linesToCheck[nextStartLine - 1]; // ignore if not the only token on the line, or not right above another checked line if (firstToken !== node || startLine === nextStartLine || !nextLine.check) { return; } // ignore if next line is a case statement, which is kind of hacky, but avoids // additional complexity for what qualifies as an outdent if (nextToken && nextToken.type === 'Keyword' && (nextToken.value === 'case' || nextToken.value === 'default')) { return; } // ignore if above a line that both introduces and ends an ident, // which catches cases like a comment above an `else if`, but not nested ifs. if (nextLine.push.length && nextLine.pop.length) { return; } markCheck(node); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (firstToken !== node || startLine === nextStartLine || !nextLine.check) {··· return; } |
| ✓ Negative was executed (else) | }··· // ignore if next line is a case statement, which is kind of hacky, but avoids |
| Branch LogicalExpression | |
| ✓ Was returned | if (firstToken !== node || startLine === nextStartLine || !nextLine.check) { |
| ✓ Was returned | if (firstToken !== node || startLine === nextStartLine || !nextLine.check) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (firstToken !== node || startLine === nextStartLine || !nextLine.check) { |
| ✓ Was returned | if (firstToken !== node || startLine === nextStartLine || !nextLine.check) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | (nextToken.value === 'case' || nextToken.value === 'default')) {··· return; } |
| ✓ Negative was executed (else) | }··· // ignore if above a line that both introduces and ends an ident, |
| Branch LogicalExpression | |
| ✓ Was returned | (nextToken.value === 'case' || nextToken.value === 'default')) { |
| ✓ Was returned | if (nextToken && nextToken.type === 'Keyword' && |
| Branch LogicalExpression | |
| ✓ Was returned | if (nextToken && nextToken.type === 'Keyword' && |
| ✗ Was not returned | if (nextToken && nextToken.type === 'Keyword' && |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | (nextToken.value === 'case' || nextToken.value === 'default')) { |
| ✓ Was returned | (nextToken.value === 'case' || nextToken.value === 'default')) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (nextLine.push.length && nextLine.pop.length) {··· return; } |
| ✓ Negative was executed (else) | }··· markCheck(node); |
| Branch LogicalExpression | |
| ✓ Was returned | if (nextLine.push.length && nextLine.pop.length) { |
| ✓ Was returned | if (nextLine.push.length && nextLine.pop.length) { |
| Function (anonymous_1302) | |
|---|---|
| ✓ Was called | var linesToCheck = file.getLines().map(function(line) {··· return { push: [], pushAltLine: [], pop: [], check: false, indentation: getIndentationFromLine(line), empty: line.match(/^\s*$/) }; }); |
| Function (anonymous_1303) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1304) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( typeof options === 'string' || typeof options === 'object', this.getOptionName() + ' option requires string or object value' ); if (typeof options === 'string') { options = { character: options }; } var lineBreaks = { CR: '\r', LF: '\n', CRLF: '\r\n' }; this._allowedLineBreak = lineBreaks[options.character]; this._reportOncePerFile = options.reportOncePerFile !== false; }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | typeof options === 'string' || typeof options === 'object', |
| ✓ Was returned | typeof options === 'string' || typeof options === 'object', |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof options === 'string') {··· options = { character: options }; } |
| ✓ Negative was executed (else) | }··· var lineBreaks = { |
| Function (anonymous_1305) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'validateLineBreaks'; }, |
| Function (anonymous_1306) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var lines = file.getLines(); if (lines.length < 2) { return; } file.getLineBreaks().some(function(lineBreak, i) { if (lineBreak !== this._allowedLineBreak) { errors.add('Invalid line break', i + 1, lines[i].length); return this._reportOncePerFile; } }, this); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (lines.length < 2) {··· return; } |
| ✓ Negative was executed (else) | }··· file.getLineBreaks().some(function(lineBreak, i) { |
| Function (anonymous_1307) | |
|---|---|
| ✓ Was called | file.getLineBreaks().some(function(lineBreak, i) {··· if (lineBreak !== this._allowedLineBreak) { errors.add('Invalid line break', i + 1, lines[i].length); return this._reportOncePerFile; } }, this); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (lineBreak !== this._allowedLineBreak) {··· errors.add('Invalid line break', i + 1, lines[i].length); return this._reportOncePerFile; } |
| ✓ Negative was executed (else) | }··· }, this); |
| Function (anonymous_1308) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1309) | |
|---|---|
| ✓ Was called | configure: function(opts) {··· assert( opts === true || typeof opts === 'number' && opts >= 1 || typeof opts === 'object', this.getOptionName() + ' option requires maximal number of items ' + 'or true value either should be removed' ); if (typeof opts === 'object') { this._options = { maximum: Infinity, ignoreBrackets: false }; if ('maximum' in opts) { assert(typeof opts.maximum === 'number' && opts.maximum >= 1, 'maximum property requires a positive number or should be removed'); this._options.maximum = opts.maximum; } if ('ignoreBrackets' in opts) { assert(opts.ignoreBrackets === true, 'ignoreBrackets property requires true value or should be removed'); this._options.ignoreBrackets = true; } } else { this._options = { maximum: opts === true ? Infinity : opts, ignoreBrackets: false }; } }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | typeof opts === 'object', |
| ✓ Was returned | opts === true ||··· typeof opts === 'number' && opts >= 1 || |
| Branch LogicalExpression | |
| ✓ Was returned | typeof opts === 'number' && opts >= 1 || |
| ✓ Was returned | opts === true || |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | typeof opts === 'number' && opts >= 1 || |
| ✓ Was returned | typeof opts === 'number' && opts >= 1 || |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof opts === 'object') {··· this._options = { maximum: Infinity, ignoreBrackets: false }; if ('maximum' in opts) { assert(typeof opts.maximum === 'number' && opts.maximum >= 1, 'maximum property requires a positive number or should be removed'); this._options.maximum = opts.maximum; } if ('ignoreBrackets' in opts) { assert(opts.ignoreBrackets === true, 'ignoreBrackets property requires true value or should be removed'); this._options.ignoreBrackets = true; } } else { |
| ✓ Negative was executed (else) | } else {··· this._options = { maximum: opts === true ? Infinity : opts, ignoreBrackets: false }; } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('maximum' in opts) {··· assert(typeof opts.maximum === 'number' && opts.maximum >= 1, 'maximum property requires a positive number or should be removed'); this._options.maximum = opts.maximum; } |
| ✓ Negative was executed (else) | }··· if ('ignoreBrackets' in opts) { |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | assert(typeof opts.maximum === 'number' && opts.maximum >= 1, |
| ✓ Was returned | assert(typeof opts.maximum === 'number' && opts.maximum >= 1, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if ('ignoreBrackets' in opts) {··· assert(opts.ignoreBrackets === true, 'ignoreBrackets property requires true value or should be removed'); this._options.ignoreBrackets = true; } |
| ✓ Negative was executed (else) | }··· } else { |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | maximum: opts === true ? Infinity : opts, |
| ✓ Negative was returned (: ...) | maximum: opts === true ? Infinity : opts, |
| Function (anonymous_1310) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'validateNewlineAfterArrayElements'; }, |
| Function (anonymous_1311) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var maximum = this._options.maximum; var ignoreBrackets = this._options.ignoreBrackets; file.iterateNodesByType(['ArrayExpression'], function(node) { var els = node.elements; var firstEl = els[0]; var lastEl = els[els.length - 1]; var bracket; var elToken; if (els.length <= maximum && node.loc.start.line === node.loc.end.line) { return; } if (!ignoreBrackets) { if (firstEl && firstEl.loc.start.line === node.loc.start.line) { bracket = file.getFirstNodeToken(node); elToken = file.getNextToken(bracket); errors.assert.differentLine({ token: bracket, nextToken: elToken, message: 'First element should be placed on new line' }); } if (lastEl && lastEl.loc.end.line === node.loc.end.line) { bracket = file.getLastNodeToken(node); elToken = file.getPrevToken(bracket); errors.assert.differentLine({ token: elToken, nextToken: bracket, message: 'Closing bracket should be placed on new line' }); } } els.forEach(function(elem) { var elToken; var comma; if (!elem) { // skip holes return; } if (firstEl !== elem) { elToken = file.getFirstNodeToken(elem); comma = file.getPrevToken(elToken); errors.assert.differentLine({ token: comma, nextToken: elToken, message: 'Multiple elements at a single line in multiline array' }); } }); }); } |
| Function (anonymous_1312) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['ArrayExpression'], function(node) {··· var els = node.elements; var firstEl = els[0]; var lastEl = els[els.length - 1]; var bracket; var elToken; if (els.length <= maximum && node.loc.start.line === node.loc.end.line) { return; } if (!ignoreBrackets) { if (firstEl && firstEl.loc.start.line === node.loc.start.line) { bracket = file.getFirstNodeToken(node); elToken = file.getNextToken(bracket); errors.assert.differentLine({ token: bracket, nextToken: elToken, message: 'First element should be placed on new line' }); } if (lastEl && lastEl.loc.end.line === node.loc.end.line) { bracket = file.getLastNodeToken(node); elToken = file.getPrevToken(bracket); errors.assert.differentLine({ token: elToken, nextToken: bracket, message: 'Closing bracket should be placed on new line' }); } } els.forEach(function(elem) { var elToken; var comma; if (!elem) { // skip holes return; } if (firstEl !== elem) { elToken = file.getFirstNodeToken(elem); comma = file.getPrevToken(elToken); errors.assert.differentLine({ token: comma, nextToken: elToken, message: 'Multiple elements at a single line in multiline array' }); } }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (els.length <= maximum && node.loc.start.line === node.loc.end.line) {··· return; } |
| ✓ Negative was executed (else) | }··· if (!ignoreBrackets) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (els.length <= maximum && node.loc.start.line === node.loc.end.line) { |
| ✓ Was returned | if (els.length <= maximum && node.loc.start.line === node.loc.end.line) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!ignoreBrackets) {··· if (firstEl && firstEl.loc.start.line === node.loc.start.line) { bracket = file.getFirstNodeToken(node); elToken = file.getNextToken(bracket); errors.assert.differentLine({ token: bracket, nextToken: elToken, message: 'First element should be placed on new line' }); } if (lastEl && lastEl.loc.end.line === node.loc.end.line) { bracket = file.getLastNodeToken(node); elToken = file.getPrevToken(bracket); errors.assert.differentLine({ token: elToken, nextToken: bracket, message: 'Closing bracket should be placed on new line' }); } } |
| ✓ Negative was executed (else) | }··· els.forEach(function(elem) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (firstEl && firstEl.loc.start.line === node.loc.start.line) {··· bracket = file.getFirstNodeToken(node); elToken = file.getNextToken(bracket); errors.assert.differentLine({ token: bracket, nextToken: elToken, message: 'First element should be placed on new line' }); } |
| ✓ Negative was executed (else) | }··· if (lastEl && lastEl.loc.end.line === node.loc.end.line) { |
| Branch LogicalExpression | |
| ✓ Was returned | if (firstEl && firstEl.loc.start.line === node.loc.start.line) { |
| ✓ Was returned | if (firstEl && firstEl.loc.start.line === node.loc.start.line) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (lastEl && lastEl.loc.end.line === node.loc.end.line) {··· bracket = file.getLastNodeToken(node); elToken = file.getPrevToken(bracket); errors.assert.differentLine({ token: elToken, nextToken: bracket, message: 'Closing bracket should be placed on new line' }); } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | if (lastEl && lastEl.loc.end.line === node.loc.end.line) { |
| ✓ Was returned | if (lastEl && lastEl.loc.end.line === node.loc.end.line) { |
| Function (anonymous_1313) | |
|---|---|
| ✓ Was called | els.forEach(function(elem) {··· var elToken; var comma; if (!elem) { // skip holes return; } if (firstEl !== elem) { elToken = file.getFirstNodeToken(elem); comma = file.getPrevToken(elToken); errors.assert.differentLine({ token: comma, nextToken: elToken, message: 'Multiple elements at a single line in multiline array' }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!elem) {··· // skip holes return; } |
| ✓ Negative was executed (else) | }··· if (firstEl !== elem) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (firstEl !== elem) {··· elToken = file.getFirstNodeToken(elem); comma = file.getPrevToken(elToken); errors.assert.differentLine({ token: comma, nextToken: elToken, message: 'Multiple elements at a single line in multiline array' }); } |
| ✓ Negative was executed (else) | }··· }); |
| Function asc | |
|---|---|
| ✓ Was called | function asc(a, b) {··· return String(a) < String(b) ? -1 : 1; } |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | return String(a) < String(b) ? -1 : 1; |
| ✓ Negative was returned (: ...) | return String(a) < String(b) ? -1 : 1; |
| Function ascInsensitive | |
|---|---|
| ✓ Was called | function ascInsensitive(a, b) {··· var lowercaseA = String(a).toLowerCase(); var lowercaseB = String(b).toLowerCase(); if (lowercaseA < lowercaseB) { return -1; } if (lowercaseA > lowercaseB) { return 1; } return asc(a, b); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (lowercaseA < lowercaseB) {··· return -1; } |
| ✓ Negative was executed (else) | }··· if (lowercaseA > lowercaseB) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (lowercaseA > lowercaseB) {··· return 1; } |
| ✓ Negative was executed (else) | }··· return asc(a, b); |
| Function ascNatural | |
|---|---|
| ✓ Was called | function ascNatural(a, b) {··· return naturalSort(a, b); } |
| Function desc | |
|---|---|
| ✓ Was called | function desc(a, b) {··· return asc(a, b) * -1; } |
| Function descInsensitive | |
|---|---|
| ✓ Was called | function descInsensitive(a, b) {··· return ascInsensitive(a, b) * -1; } |
| Function descNatural | |
|---|---|
| ✓ Was called | function descNatural(a, b) {··· return naturalSort(a, b) * -1; } |
| Function (anonymous_1320) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1321) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( options === true || Object.keys(methods).indexOf(options) !== -1, this.getOptionName() + ' option requires a true value or should be removed' ); this._sort = methods[options] || methods.asc; }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | options === true || Object.keys(methods).indexOf(options) !== -1, |
| ✗ Was not returned | options === true || Object.keys(methods).indexOf(options) !== -1, |
| Branch LogicalExpression | |
|---|---|
| ✗ Was not returned | this._sort = methods[options] || methods.asc; |
| ✓ Was returned | this._sort = methods[options] || methods.asc; |
| Function (anonymous_1322) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'validateOrderInObjectKeys'; }, |
| Function (anonymous_1323) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var sort = this._sort; file.iterateNodesByType('ObjectExpression', function(node) { var keys = node.properties.map(function(property) { return (property.key.name || property.key.value); }); var sorted = keys.slice(0).sort(sort); var unsorted; for (var i = 0; i < keys.length; i++) { if (keys[i] !== sorted[i]) { unsorted = i; break; } } if (undefined !== unsorted) { errors.add( 'Object keys must be in ' + (/asc/.test(sort.name) ? 'ascending' : 'descending') + ' order', node.properties[unsorted].loc.start ); } }); } |
| Function (anonymous_1324) | |
|---|---|
| ✓ Was called | file.iterateNodesByType('ObjectExpression', function(node) {··· var keys = node.properties.map(function(property) { return (property.key.name || property.key.value); }); var sorted = keys.slice(0).sort(sort); var unsorted; for (var i = 0; i < keys.length; i++) { if (keys[i] !== sorted[i]) { unsorted = i; break; } } if (undefined !== unsorted) { errors.add( 'Object keys must be in ' + (/asc/.test(sort.name) ? 'ascending' : 'descending') + ' order', node.properties[unsorted].loc.start ); } }); |
| Function (anonymous_1325) | |
|---|---|
| ✓ Was called | var keys = node.properties.map(function(property) {··· return (property.key.name || property.key.value); }); |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | return (property.key.name || property.key.value); |
| ✓ Was returned | return (property.key.name || property.key.value); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (keys[i] !== sorted[i]) {··· unsorted = i; break; } |
| ✓ Negative was executed (else) | }··· } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (undefined !== unsorted) {··· errors.add( 'Object keys must be in ' + (/asc/.test(sort.name) ? 'ascending' : 'descending') + ' order', node.properties[unsorted].loc.start ); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | 'Object keys must be in ' + (/asc/.test(sort.name) ? 'ascending' : 'descending') + ' order', |
| ✓ Negative was returned (: ...) | 'Object keys must be in ' + (/asc/.test(sort.name) ? 'ascending' : 'descending') + ' order', |
| Function (anonymous_1326) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1327) | |
|---|---|
| ✓ Was called | configure: function(options) {··· assert( typeof options === 'string' && /^[ ]?,[ ]?$/.test(options), this.getOptionName() + ' option requires string value containing only a comma and optional spaces' ); this._separator = options; }, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | typeof options === 'string' && /^[ ]?,[ ]?$/.test(options), |
| ✓ Was returned | typeof options === 'string' && /^[ ]?,[ ]?$/.test(options), |
| Function (anonymous_1328) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'validateParameterSeparator'; }, |
| Function (anonymous_1329) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var separators = this._separator.split(','); var whitespaceBeforeComma = Boolean(separators.shift()); var whitespaceAfterComma = Boolean(separators.pop()); file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) { node.params.forEach(function(paramNode) { var prevParamToken = file.getFirstNodeToken(paramNode); var punctuatorToken = file.getNextToken(prevParamToken); if (punctuatorToken.value === ',') { if (whitespaceBeforeComma) { errors.assert.spacesBetween({ token: prevParamToken, nextToken: punctuatorToken, exactly: 1, message: 'One space required after function parameter \'' + prevParamToken.value + '\'' }); } else { errors.assert.noWhitespaceBetween({ token: prevParamToken, nextToken: punctuatorToken, message: 'Unexpected space after function parameter \'' + prevParamToken.value + '\'' }); } var nextParamToken = file.getNextToken(punctuatorToken); if (whitespaceAfterComma) { errors.assert.spacesBetween({ token: punctuatorToken, nextToken: nextParamToken, exactly: 1, message: 'One space required before function parameter \'' + nextParamToken.value + '\'' }); } else { errors.assert.noWhitespaceBetween({ token: punctuatorToken, nextToken: nextParamToken, message: 'Unexpected space before function parameter \'' + nextParamToken.value + '\'' }); } } }); }); } |
| Function (anonymous_1330) | |
|---|---|
| ✓ Was called | file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) {··· node.params.forEach(function(paramNode) { var prevParamToken = file.getFirstNodeToken(paramNode); var punctuatorToken = file.getNextToken(prevParamToken); if (punctuatorToken.value === ',') { if (whitespaceBeforeComma) { errors.assert.spacesBetween({ token: prevParamToken, nextToken: punctuatorToken, exactly: 1, message: 'One space required after function parameter \'' + prevParamToken.value + '\'' }); } else { errors.assert.noWhitespaceBetween({ token: prevParamToken, nextToken: punctuatorToken, message: 'Unexpected space after function parameter \'' + prevParamToken.value + '\'' }); } var nextParamToken = file.getNextToken(punctuatorToken); if (whitespaceAfterComma) { errors.assert.spacesBetween({ token: punctuatorToken, nextToken: nextParamToken, exactly: 1, message: 'One space required before function parameter \'' + nextParamToken.value + '\'' }); } else { errors.assert.noWhitespaceBetween({ token: punctuatorToken, nextToken: nextParamToken, message: 'Unexpected space before function parameter \'' + nextParamToken.value + '\'' }); } } }); }); |
| Function (anonymous_1331) | |
|---|---|
| ✓ Was called | node.params.forEach(function(paramNode) {··· var prevParamToken = file.getFirstNodeToken(paramNode); var punctuatorToken = file.getNextToken(prevParamToken); if (punctuatorToken.value === ',') { if (whitespaceBeforeComma) { errors.assert.spacesBetween({ token: prevParamToken, nextToken: punctuatorToken, exactly: 1, message: 'One space required after function parameter \'' + prevParamToken.value + '\'' }); } else { errors.assert.noWhitespaceBetween({ token: prevParamToken, nextToken: punctuatorToken, message: 'Unexpected space after function parameter \'' + prevParamToken.value + '\'' }); } var nextParamToken = file.getNextToken(punctuatorToken); if (whitespaceAfterComma) { errors.assert.spacesBetween({ token: punctuatorToken, nextToken: nextParamToken, exactly: 1, message: 'One space required before function parameter \'' + nextParamToken.value + '\'' }); } else { errors.assert.noWhitespaceBetween({ token: punctuatorToken, nextToken: nextParamToken, message: 'Unexpected space before function parameter \'' + nextParamToken.value + '\'' }); } } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (punctuatorToken.value === ',') {··· if (whitespaceBeforeComma) { errors.assert.spacesBetween({ token: prevParamToken, nextToken: punctuatorToken, exactly: 1, message: 'One space required after function parameter \'' + prevParamToken.value + '\'' }); } else { errors.assert.noWhitespaceBetween({ token: prevParamToken, nextToken: punctuatorToken, message: 'Unexpected space after function parameter \'' + prevParamToken.value + '\'' }); } var nextParamToken = file.getNextToken(punctuatorToken); if (whitespaceAfterComma) { errors.assert.spacesBetween({ token: punctuatorToken, nextToken: nextParamToken, exactly: 1, message: 'One space required before function parameter \'' + nextParamToken.value + '\'' }); } else { errors.assert.noWhitespaceBetween({ token: punctuatorToken, nextToken: nextParamToken, message: 'Unexpected space before function parameter \'' + nextParamToken.value + '\'' }); } } |
| ✓ Negative was executed (else) | }··· }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (whitespaceBeforeComma) {··· errors.assert.spacesBetween({ token: prevParamToken, nextToken: punctuatorToken, exactly: 1, message: 'One space required after function parameter \'' + prevParamToken.value + '\'' }); } else { |
| ✓ Negative was executed (else) | } else {··· errors.assert.noWhitespaceBetween({ token: prevParamToken, nextToken: punctuatorToken, message: 'Unexpected space after function parameter \'' + prevParamToken.value + '\'' }); } |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (whitespaceAfterComma) {··· errors.assert.spacesBetween({ token: punctuatorToken, nextToken: nextParamToken, exactly: 1, message: 'One space required before function parameter \'' + nextParamToken.value + '\'' }); } else { |
| ✓ Negative was executed (else) | } else {··· errors.assert.noWhitespaceBetween({ token: punctuatorToken, nextToken: nextParamToken, message: 'Unexpected space before function parameter \'' + nextParamToken.value + '\'' }); } |
| Function (anonymous_1332) | |
|---|---|
| ✓ Was called | module.exports = function() {}; |
| Function (anonymous_1333) | |
|---|---|
| ✓ Was called | configure: function(quoteMark) {··· this._allowEscape = false; this._ignoreJSX = false; if (typeof quoteMark === 'object') { assert( typeof quoteMark.escape === 'boolean' && quoteMark.mark !== undefined, this.getOptionName() + ' option requires the "escape" and "mark" property to be defined' ); this._allowEscape = quoteMark.escape; if (quoteMark.ignoreJSX) { this._ignoreJSX = quoteMark.ignoreJSX; } quoteMark = quoteMark.mark; } assert( quoteMark === '"' || quoteMark === '\'' || quoteMark === true, this.getOptionName() + ' option requires \'"\', "\'", or boolean true' ); assert( quoteMark === '"' || quoteMark === '\'' || quoteMark === true, this.getOptionName() + ' option requires \'"\', "\'", or boolean true' ); this._quoteMark = quoteMark; }, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (typeof quoteMark === 'object') {··· assert( typeof quoteMark.escape === 'boolean' && quoteMark.mark !== undefined, this.getOptionName() + ' option requires the "escape" and "mark" property to be defined' ); this._allowEscape = quoteMark.escape; if (quoteMark.ignoreJSX) { this._ignoreJSX = quoteMark.ignoreJSX; } quoteMark = quoteMark.mark; } |
| ✓ Negative was executed (else) | }··· assert( |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | typeof quoteMark.escape === 'boolean' && quoteMark.mark !== undefined, |
| ✓ Was returned | typeof quoteMark.escape === 'boolean' && quoteMark.mark !== undefined, |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (quoteMark.ignoreJSX) {··· this._ignoreJSX = quoteMark.ignoreJSX; } |
| ✓ Negative was executed (else) | }··· quoteMark = quoteMark.mark; |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | quoteMark === '"' || quoteMark === '\'' || quoteMark === true, |
| ✓ Was returned | quoteMark === '"' || quoteMark === '\'' || quoteMark === true, |
| Branch LogicalExpression | |
| ✓ Was returned | quoteMark === '"' || quoteMark === '\'' || quoteMark === true, |
| ✓ Was returned | quoteMark === '"' || quoteMark === '\'' || quoteMark === true, |
| Branch LogicalExpression | |
|---|---|
| ✓ Was returned | quoteMark === '"' || quoteMark === '\'' || quoteMark === true, |
| ✓ Was returned | quoteMark === '"' || quoteMark === '\'' || quoteMark === true, |
| Branch LogicalExpression | |
| ✓ Was returned | quoteMark === '"' || quoteMark === '\'' || quoteMark === true, |
| ✓ Was returned | quoteMark === '"' || quoteMark === '\'' || quoteMark === true, |
| Function (anonymous_1334) | |
|---|---|
| ✓ Was called | getOptionName: function() {··· return 'validateQuoteMarks'; }, |
| Function (anonymous_1335) | |
|---|---|
| ✓ Was called | check: function(file, errors) {··· var quoteMark = this._quoteMark; var allowEscape = this._allowEscape; var ignoreJSX = this._ignoreJSX; var opposite = { '"': '\'', '\'': '"' }; file.iterateTokensByType('String', function(token) { var node; if (ignoreJSX) { node = file.getNodeByRange(token.range[0]).parentNode; if (node && node.type === 'JSXAttribute') { return; } } var str = token.value; var mark = str[0]; var stripped = str.substring(1, str.length - 1); if (quoteMark === true) { quoteMark = mark; } if (mark !== quoteMark) { if (allowEscape && stripped.indexOf(opposite[mark]) > -1) { return; } errors.cast({ message: 'Invalid quote mark found', line: token.loc.start.line, column: token.loc.start.column, additional: token }); } }); }, |
| Function (anonymous_1336) | |
|---|---|
| ✓ Was called | file.iterateTokensByType('String', function(token) {··· var node; if (ignoreJSX) { node = file.getNodeByRange(token.range[0]).parentNode; if (node && node.type === 'JSXAttribute') { return; } } var str = token.value; var mark = str[0]; var stripped = str.substring(1, str.length - 1); if (quoteMark === true) { quoteMark = mark; } if (mark !== quoteMark) { if (allowEscape && stripped.indexOf(opposite[mark]) > -1) { return; } errors.cast({ message: 'Invalid quote mark found', line: token.loc.start.line, column: token.loc.start.column, additional: token }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (ignoreJSX) {··· node = file.getNodeByRange(token.range[0]).parentNode; if (node && node.type === 'JSXAttribute') { return; } } |
| ✓ Negative was executed (else) | }··· var str = token.value; |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (node && node.type === 'JSXAttribute') {··· return; } |
| ✓ Negative was executed (else) | }··· } |
| Branch LogicalExpression | |
| ✓ Was returned | if (node && node.type === 'JSXAttribute') { |
| ✓ Was returned | if (node && node.type === 'JSXAttribute') { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (quoteMark === true) {··· quoteMark = mark; } |
| ✓ Negative was executed (else) | }··· if (mark !== quoteMark) { |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (mark !== quoteMark) {··· if (allowEscape && stripped.indexOf(opposite[mark]) > -1) { return; } errors.cast({ message: 'Invalid quote mark found', line: token.loc.start.line, column: token.loc.start.column, additional: token }); } |
| ✓ Negative was executed (else) | }··· }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (allowEscape && stripped.indexOf(opposite[mark]) > -1) {··· return; } |
| ✓ Negative was executed (else) | }··· errors.cast({ |
| Branch LogicalExpression | |
| ✓ Was returned | if (allowEscape && stripped.indexOf(opposite[mark]) > -1) { |
| ✓ Was returned | if (allowEscape && stripped.indexOf(opposite[mark]) > -1) { |
| Function (anonymous_1337) | |
|---|---|
| ✓ Was called | _fix: function(file, error) {··· var token = error.additional; var fixer = require(this._quoteMark === '"' ? 'to-double-quotes' : 'to-single-quotes'); token.value = fixer(token.value); } |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | var fixer = require(this._quoteMark === '"' ? 'to-double-quotes' : 'to-single-quotes'); |
| ✓ Negative was returned (: ...) | var fixer = require(this._quoteMark === '"' ? 'to-double-quotes' : 'to-single-quotes'); |
| Function escapeAttrValue | |
|---|---|
| ✓ Was called | function escapeAttrValue(attrValue) {··· return String(attrValue) .replace(/&/g, '&') .replace(/"/g, '"') .replace(/</g, '<') .replace(/>/g, '>'); } |
| Function (anonymous_1339) | |
|---|---|
| ✓ Was called | module.exports = function(errorCollection) {··· console.log('<?xml version="1.0" encoding="utf-8"?>\n<checkstyle version="4.3">'); errorCollection.forEach(function(errors) { console.log(' <file name="' + escapeAttrValue(errors.getFilename()) + '">'); errors.getErrorList().forEach(function(error) { console.log( ' <error ' + 'line="' + error.line + '" ' + 'column="' + (error.column + 1) + '" ' + 'severity="error" ' + 'message="' + escapeAttrValue(error.message) + '" ' + 'source="jscs" />' ); }); console.log(' </file>'); }); console.log('</checkstyle>'); }; |
| Function (anonymous_1340) | |
|---|---|
| ✓ Was called | errorCollection.forEach(function(errors) {··· console.log(' <file name="' + escapeAttrValue(errors.getFilename()) + '">'); errors.getErrorList().forEach(function(error) { console.log( ' <error ' + 'line="' + error.line + '" ' + 'column="' + (error.column + 1) + '" ' + 'severity="error" ' + 'message="' + escapeAttrValue(error.message) + '" ' + 'source="jscs" />' ); }); console.log(' </file>'); }); |
| Function (anonymous_1341) | |
|---|---|
| ✓ Was called | errors.getErrorList().forEach(function(error) {··· console.log( ' <error ' + 'line="' + error.line + '" ' + 'column="' + (error.column + 1) + '" ' + 'severity="error" ' + 'message="' + escapeAttrValue(error.message) + '" ' + 'source="jscs" />' ); }); |
| Function (anonymous_1342) | |
|---|---|
| ✓ Was called | module.exports = function(errorsCollection) {··· var errorCount = 0; /** * Formatting every error set. */ errorsCollection.forEach(function(errors) { if (!errors.isEmpty()) { /** * Formatting every single error. */ errors.getErrorList().forEach(function(error) { errorCount++; console.log(errors.explainError(error, true) + '\n'); }); } }); if (errorCount) { /** * Printing summary. */ console.log('\n' + errorCount + ' code style ' + (errorCount === 1 ? 'error' : 'errors') + ' found.'); } }; |
| Function (anonymous_1343) | |
|---|---|
| ✓ Was called | errorsCollection.forEach(function(errors) {··· if (!errors.isEmpty()) { /** * Formatting every single error. */ errors.getErrorList().forEach(function(error) { errorCount++; console.log(errors.explainError(error, true) + '\n'); }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!errors.isEmpty()) {··· /** * Formatting every single error. */ errors.getErrorList().forEach(function(error) { errorCount++; console.log(errors.explainError(error, true) + '\n'); }); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_1344) | |
|---|---|
| ✓ Was called | errors.getErrorList().forEach(function(error) {··· errorCount++; console.log(errors.explainError(error, true) + '\n'); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (errorCount) {··· /** * Printing summary. */ console.log('\n' + errorCount + ' code style ' + (errorCount === 1 ? 'error' : 'errors') + ' found.'); } |
| ✓ Negative was executed (else) | }··· }; |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | console.log('\n' + errorCount + ' code style ' + (errorCount === 1 ? 'error' : 'errors') + ' found.'); |
| ✓ Negative was returned (: ...) | console.log('\n' + errorCount + ' code style ' + (errorCount === 1 ? 'error' : 'errors') + ' found.'); |
| Function (anonymous_1345) | |
|---|---|
| ✓ Was called | module.exports = function(errorsCollection) {··· var errorCount = 0; /** * Formatting every error set. */ errorsCollection.forEach(function(errors) { var file = errors.getFilename(); if (!errors.isEmpty()) { errors.getErrorList().forEach(function(error) { errorCount++; console.log(util.format('%s: line %d, col %d, %s', file, error.line, error.column, error.message)); }); } }); }; |
| Function (anonymous_1346) | |
|---|---|
| ✓ Was called | errorsCollection.forEach(function(errors) {··· var file = errors.getFilename(); if (!errors.isEmpty()) { errors.getErrorList().forEach(function(error) { errorCount++; console.log(util.format('%s: line %d, col %d, %s', file, error.line, error.column, error.message)); }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!errors.isEmpty()) {··· errors.getErrorList().forEach(function(error) { errorCount++; console.log(util.format('%s: line %d, col %d, %s', file, error.line, error.column, error.message)); }); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_1347) | |
|---|---|
| ✓ Was called | errors.getErrorList().forEach(function(error) {··· errorCount++; console.log(util.format('%s: line %d, col %d, %s', file, error.line, error.column, error.message)); }); |
| Function (anonymous_1348) | |
|---|---|
| ✓ Was called | module.exports = function(errorsCollection) {··· errorsCollection.forEach(function(errors) { if (!errors.isEmpty()) { var file = errors.getFilename(); var out = errors.getErrorList().map(function(error) { return util.format('%s: line %d, col %d, %s', file, error.line, error.column, error.message); }); console.log(out.join('\n')); } }); }; |
| Function (anonymous_1349) | |
|---|---|
| ✓ Was called | errorsCollection.forEach(function(errors) {··· if (!errors.isEmpty()) { var file = errors.getFilename(); var out = errors.getErrorList().map(function(error) { return util.format('%s: line %d, col %d, %s', file, error.line, error.column, error.message); }); console.log(out.join('\n')); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!errors.isEmpty()) {··· var file = errors.getFilename(); var out = errors.getErrorList().map(function(error) { return util.format('%s: line %d, col %d, %s', file, error.line, error.column, error.message); }); console.log(out.join('\n')); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_1350) | |
|---|---|
| ✓ Was called | var out = errors.getErrorList().map(function(error) {··· return util.format('%s: line %d, col %d, %s', file, error.line, error.column, error.message); }); |
| Function (anonymous_1351) | |
|---|---|
| ✓ Was called | module.exports = function(errorsCollection) {··· var jsonOutput = {}; var anyError = false; errorsCollection.forEach(function(errors) { var file = errors.getFilename(); var arr = jsonOutput[file] = []; if (!errors.isEmpty()) { anyError = true; } errors.getErrorList().forEach(function(error) { arr.push({ line: error.line, column: error.column + 1, message: error.message }); }); }); if (anyError) { console.log(JSON.stringify(jsonOutput)); } }; |
| Function (anonymous_1352) | |
|---|---|
| ✓ Was called | errorsCollection.forEach(function(errors) {··· var file = errors.getFilename(); var arr = jsonOutput[file] = []; if (!errors.isEmpty()) { anyError = true; } errors.getErrorList().forEach(function(error) { arr.push({ line: error.line, column: error.column + 1, message: error.message }); }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!errors.isEmpty()) {··· anyError = true; } |
| ✓ Negative was executed (else) | }··· errors.getErrorList().forEach(function(error) { |
| Function (anonymous_1353) | |
|---|---|
| ✓ Was called | errors.getErrorList().forEach(function(error) {··· arr.push({ line: error.line, column: error.column + 1, message: error.message }); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (anyError) {··· console.log(JSON.stringify(jsonOutput)); } |
| ✓ Negative was executed (else) | }··· }; |
| Function (anonymous_1354) | |
|---|---|
| ✓ Was called | module.exports = function(errorCollection) {··· var i = 0; var testsuite = xml.create('testsuite'); testsuite.att('name', 'JSCS'); testsuite.att('tests', errorCollection.length); errorCollection.forEach(function(errors) { var errorsCount = errors.getErrorCount(); var testcase = testsuite.ele('testcase', { name: errors.getFilename(), failures: errorsCount }); i += errorsCount; errors.getErrorList().forEach(function(error) { testcase.ele('failure', {}, errors.explainError(error)); }); }); testsuite.att('failures', i); console.log(testsuite.end({pretty: true})); }; |
| Function (anonymous_1355) | |
|---|---|
| ✓ Was called | errorCollection.forEach(function(errors) {··· var errorsCount = errors.getErrorCount(); var testcase = testsuite.ele('testcase', { name: errors.getFilename(), failures: errorsCount }); i += errorsCount; errors.getErrorList().forEach(function(error) { testcase.ele('failure', {}, errors.explainError(error)); }); }); |
| Function (anonymous_1356) | |
|---|---|
| ✓ Was called | errors.getErrorList().forEach(function(error) {··· testcase.ele('failure', {}, errors.explainError(error)); }); |
| Function (anonymous_1357) | |
|---|---|
| ✓ Was called | module.exports = function(errorsCollection) {··· var Table = require('cli-table'); var hasError = false; var errorsByRule = {}; var style = { 'padding-left': 0, 'padding-right': 0, 'head': ['yellow'], 'border': ['red'], 'compact': false }; var errorsByFileTable = new Table({ 'head': ['Path', 'Total Errors'], 'colAligns': [ 'middle', 'middle', 'middle' ], 'colWidths': [62, 18], 'style': style }); var errorsByRuleTable = new Table({ 'head': ['Rule', 'Total Errors', 'Files With Errors'], 'colAligns': [ 'middle', 'middle', 'middle' ], 'colWidths': [49, 12, 18], 'style': style }); errorsCollection.forEach(function(errors) { var fileName = errors.getFilename(); if (!errors.isEmpty()) { hasError = true; errorsByFileTable.push([fileName, errors.getErrorCount()]); errors.getErrorList().forEach(function(error) { if (error.rule in errorsByRule) { errorsByRule[error.rule] .count += 1; } else { errorsByRule[error.rule] = { count: 1, files: {} }; } errorsByRule[error.rule].files[fileName] = 1; }); } }); var totalErrors = 0; var totalFilesWithErrors = 0; Object.getOwnPropertyNames(errorsByRule).forEach(function(ruleName) { var fileCount = Object.getOwnPropertyNames(errorsByRule[ruleName].files).length; errorsByRuleTable.push([ruleName, errorsByRule[ruleName].count, fileCount]); totalErrors += errorsByRule[ruleName].count; totalFilesWithErrors += fileCount; }); errorsByRuleTable.push(['All', totalErrors, totalFilesWithErrors]); if (hasError === false) { console.log('No code style errors found.'); } else { console.log(errorsByFileTable.toString()); console.log(errorsByRuleTable.toString()); } }; |
| Function (anonymous_1358) | |
|---|---|
| ✓ Was called | errorsCollection.forEach(function(errors) {··· var fileName = errors.getFilename(); if (!errors.isEmpty()) { hasError = true; errorsByFileTable.push([fileName, errors.getErrorCount()]); errors.getErrorList().forEach(function(error) { if (error.rule in errorsByRule) { errorsByRule[error.rule] .count += 1; } else { errorsByRule[error.rule] = { count: 1, files: {} }; } errorsByRule[error.rule].files[fileName] = 1; }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!errors.isEmpty()) {··· hasError = true; errorsByFileTable.push([fileName, errors.getErrorCount()]); errors.getErrorList().forEach(function(error) { if (error.rule in errorsByRule) { errorsByRule[error.rule] .count += 1; } else { errorsByRule[error.rule] = { count: 1, files: {} }; } errorsByRule[error.rule].files[fileName] = 1; }); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_1359) | |
|---|---|
| ✓ Was called | errors.getErrorList().forEach(function(error) {··· if (error.rule in errorsByRule) { errorsByRule[error.rule] .count += 1; } else { errorsByRule[error.rule] = { count: 1, files: {} }; } errorsByRule[error.rule].files[fileName] = 1; }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (error.rule in errorsByRule) {··· errorsByRule[error.rule] .count += 1; } else { |
| ✓ Negative was executed (else) | } else {··· errorsByRule[error.rule] = { count: 1, files: {} }; } |
| Function (anonymous_1360) | |
|---|---|
| ✓ Was called | Object.getOwnPropertyNames(errorsByRule).forEach(function(ruleName) {··· var fileCount = Object.getOwnPropertyNames(errorsByRule[ruleName].files).length; errorsByRuleTable.push([ruleName, errorsByRule[ruleName].count, fileCount]); totalErrors += errorsByRule[ruleName].count; totalFilesWithErrors += fileCount; }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (hasError === false) {··· console.log('No code style errors found.'); } else { |
| ✓ Negative was executed (else) | } else {··· console.log(errorsByFileTable.toString()); console.log(errorsByRuleTable.toString()); } |
| Function (anonymous_1361) | |
|---|---|
| ✓ Was called | module.exports = function(errorsCollection) {··· var errorCount = 0; /** * Formatting every error set. */ errorsCollection.forEach(function(errors) { if (!errors.isEmpty()) { /** * Formatting every single error. */ errors.getErrorList().forEach(function(error) { errorCount++; console.log(errors.explainError(error) + '\n'); }); } }); if (errorCount) { /** * Printing summary. */ console.log('\n' + errorCount + ' code style ' + (errorCount === 1 ? 'error' : 'errors') + ' found.'); } }; |
| Function (anonymous_1362) | |
|---|---|
| ✓ Was called | errorsCollection.forEach(function(errors) {··· if (!errors.isEmpty()) { /** * Formatting every single error. */ errors.getErrorList().forEach(function(error) { errorCount++; console.log(errors.explainError(error) + '\n'); }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!errors.isEmpty()) {··· /** * Formatting every single error. */ errors.getErrorList().forEach(function(error) { errorCount++; console.log(errors.explainError(error) + '\n'); }); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_1363) | |
|---|---|
| ✓ Was called | errors.getErrorList().forEach(function(error) {··· errorCount++; console.log(errors.explainError(error) + '\n'); }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (errorCount) {··· /** * Printing summary. */ console.log('\n' + errorCount + ' code style ' + (errorCount === 1 ? 'error' : 'errors') + ' found.'); } |
| ✓ Negative was executed (else) | }··· }; |
| Branch ConditionalExpression | |
|---|---|
| ✓ Positive was returned (? ...) | console.log('\n' + errorCount + ' code style ' + (errorCount === 1 ? 'error' : 'errors') + ' found.'); |
| ✓ Negative was returned (: ...) | console.log('\n' + errorCount + ' code style ' + (errorCount === 1 ? 'error' : 'errors') + ' found.'); |
| Function (anonymous_1364) | |
|---|---|
| ✓ Was called | module.exports = function(errorsCollection) {··· errorsCollection.forEach(function(errors) { var file = errors.getFilename(); if (!errors.isEmpty()) { errors.getErrorList().forEach(function(error) { console.log(util.format('%s:%d:%d: %s', file, error.line, error.column, error.message)); }); } }); }; |
| Function (anonymous_1365) | |
|---|---|
| ✓ Was called | errorsCollection.forEach(function(errors) {··· var file = errors.getFilename(); if (!errors.isEmpty()) { errors.getErrorList().forEach(function(error) { console.log(util.format('%s:%d:%d: %s', file, error.line, error.column, error.message)); }); } }); |
| Branch IfStatement | |
|---|---|
| ✓ Positive was executed (if) | if (!errors.isEmpty()) {··· errors.getErrorList().forEach(function(error) { console.log(util.format('%s:%d:%d: %s', file, error.line, error.column, error.message)); }); } |
| ✓ Negative was executed (else) | }··· }); |
| Function (anonymous_1366) | |
|---|---|
| ✓ Was called | errors.getErrorList().forEach(function(error) {··· console.log(util.format('%s:%d:%d: %s', file, error.line, error.column, error.message)); }); |